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 Library | Swift | Python |
|---|---|---|
| variable | var name = "Shawn" | name = "Shawn" |
| constants | let name = "Shawn" | Not support But UPPERCASED Naming indicates constants It’s like a implicit rule in Python |
| string | "Hello World!"Multiline String """Extended Delimiters #"Hello\n Swift"#It will print Hello\n Swift | "Hello World!"Swift can’t use single quote but Python can use |
| formatted string | let name = "Shawn" | name = "Shawn"f means formatted string |
| capitalized | var greeting = “shawn baek” print(greeting.capitalized) //’Shawn Baek’ | name = “shawn baek” print(name.title()) //’Shawn Baek’ |
| uppercased / lowercased | var 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’ |
| trimPrefix | var blogUrl = “https://shawnbaek.com” blogUrl.trimPrefix(“https://”) //’shawnbaek.com’ | blog_url = ‘https://shawnbaek.com’ blog_url.removeprefix(‘https://’) //’shawnbaek.com’ |
| pow | var 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