在下列狀況下,避免使用無關的空格:python
Yes: spam(ham[1], {eggs: 2}) No: spam( ham[ 1 ], { eggs: 2 } )
Yes: if x == 4: print x, y; x, y = y, x No: if x == 4 : print x , y ; x , y = y , x
ham[1:9], ham[1:9:3], ham[:9:3], ham[1::3], ham[1:9:] ham[lower:upper], ham[lower:upper:], ham[lower::step] ham[lower+offset : upper+offset] ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)] ham[lower + offset : upper + offset]
不推薦編輯器
ham[lower + offset:upper + offset] ham[1: 9], ham[1 :9], ham[1:9 :3] ham[lower : : upper] ham[ : upper]
Yes: spam(1) No: spam (1)
Yes: dct['key'] = lst[index] No: dct ['key'] = lst [index]
x = 1 y = 2 long_variable = 3
不推薦:函數
x = 1 y = 2 long_variable = 3
i = i + 1 submitted += 1 x = x*2 - 1 hypot2 = x*x + y*y c = (a+b) * (a-b)
不推薦:this
i=i+1 submitted +=1 x = x * 2 - 1 hypot2 = x * x + y * y c = (a + b) * (a - b)
def complex(real, imag=0.0): return magic(r=real, i=imag)
不推薦:spa
def complex(real, imag = 0.0): return magic(r = real, i = imag)
def munge(input: AnyStr): ... def munge() -> AnyStr: ...
不推薦:blog
def munge(input:AnyStr): ... def munge()->PosInt: ...
def munge(sep: AnyStr = None): ... def munge(input: AnyStr, sep: AnyStr = None, limit=1000): ...
不推薦:索引
def munge(input: AnyStr=None): ... def munge(input: AnyStr, limit = 1000): ...
if foo == 'blah': do_blah_thing() do_one() do_two() do_three()
不推薦:three
if foo == 'blah': do_blah_thing() do_one(); do_two(); do_three()
if foo == 'blah': do_blah_thing() for x in lst: total += x while t < 10: t = delay()
不推薦:input
if foo == 'blah': do_blah_thing() else: do_non_blah_thing() try: something() finally: cleanup() do_one(); do_two(); do_three(long, argument, list, like, this) if foo == 'blah': one(); two(); three()