I asked my self Is python worth to learn for iOS development? My answer is Yes.

Because I can use it for

  • Build scripts
  • Core ML + coreml tools
  • BE for Mobile (Django)

Getting Principles

  • You can read the list of the python principles by importing this
import this

Cheatsheet

Standard LibrarySwiftPython
variablevar name = "Shawn"name = "Shawn"
constantslet name = "Shawn"Not support
But UPPERCASED Naming indicates constants It’s like a implicit rule in Python
string"Hello World!"

Multiline String
"""
Hello
Swift
"""


Extended Delimiters
#"Hello\n Swift"#

It will print Hello\n Swift
"Hello World!"
'Hello World!'


Swift can’t use single quote but Python can use


formatted stringlet name = "Shawn"
"My name is \(name)"
name = "Shawn"
f"My name is {name}"


f means formatted string
capitalizedvar greeting = “shawn baek”
print(greeting.capitalized)
//’Shawn Baek’
name = “shawn baek”
print(name.title())

//’Shawn Baek’
uppercased / lowercasedvar greeting = “Shawn Baek”

print(greeting.uppercased())
//’SHAWN BAEK’

print(greeting.lowercased())
//’shawn baek’
name = “Shawn Baek”
print(name.upper())
//’SHAWN BAEK’

print(name.lower())
//’shawn baek’
trimmingCharacters(in: .whitespacesAndNewlines)var greeting = ” Shawn Baek “

//MARK: Remove leading / trailing spaces

greeting.trimmingCharacters(in: .whitespacesAndNewlines)

//’Shawn Baek’
name = ” Shawn Baek “

name.rstrip()
// ‘ Shawn Baek’

name.lstrip()
//’Shawn Baek ‘

name.strip()
//’Shawn Baek’
trimPrefixvar blogUrl = “https://shawnbaek.com”
blogUrl.trimPrefix(“https://”)

//’shawnbaek.com’
blog_url = ‘https://shawnbaek.com’

blog_url.removeprefix(‘https://’)
//’shawnbaek.com’
powvar number = pow(3.0, 2.0)

print(number)
//9.0
number = 3.0 ** 2

print(number)
//9.0
comment//Hello World#Hello World

Leave a comment

Quote of the week

"People ask me what I do in the winter when there's no baseball. I'll tell you what I do. I stare out the window and wait for spring."

~ Rogers Hornsby