A quick and dirty syntax translation guide to ease the transition between Python and Julia.
- Arrays in Julia are indexed starting from 1.
| Python | Julia |
|---|---|
| True | true |
| False | false |
| None | nothing |
| type( obj ) | typeof( obj ) |
| {} | Dict{KeyType,ValueType}() |
| elif | elseif |
| Python | Julia |
|---|---|
| str1 + str2 | string( str1, str2 ) |
| len( str1 ) | length( str1 ) |
| Python | Julia |
|---|---|
| m = re.match( r"(\d+):(\d+)", mystr ) | m = match( r"(\d+):(\d+)", mystr ) |
m is not None |
m != nothing |
| arr = m.groups() | arr = m.captures |
| Python | Julia |
|---|---|
| f = open( "file.txt" ) | f = open( "file.txt") |
| for line in f | for line in eachline( f ) |
| f.close() | close( f ) |
Now there is a
startswithfunction inBase.