code is read much more often than it is written
| Indentation | Use 4 spaces per indentation level. Don't use tabs. Never mix tabs and spaces. |
| Maximum Line Length | Limit all lines to a maximum of 79 characters. |
| Deprecato | ||
|---|---|---|
| 1 |
spam(ham[1], {eggs: 2})
|
spam( ham[ 1 ], { eggs: 2 } )
|
| 2 |
if x == 4: print x, y; x |
if x == 4 : print x , y ; x |
| 3 |
spam(1) |
spam (1) |
| 4 |
dict['key'] = list[index] |
dict ['key'] = list [index] |
| 5 |
x = 1 y = 2 long_variable = 3 |
x = 1 y = 2 long_variable = 3 |
| 6 |
i = i + 1 submitted += 1 x = x * 2 - 1 hypot2 = x * x + y * y c = (a + b) * (a - b) |
i=i+1 submitted +=1 x = x*2 - 1 hypot2 = x*x + y*y c = (a+b) * (a-b) |
| 7:8 |
def complex(real, imag=0.0): return magic(r=real, i=imag) |
def complex(real, imag = 0.0): return magic(r = real, i = imag) |
Python coders from non-English speaking countries: please write your comments
in English, unless you are 120% sure that the code will never be read by people
who don't speak your language.
Don't do this:
x = x + 1 # Increment x
But sometimes, this is useful:
x = x + 1 # Compensate for border