1, the binary operator on each side a space [=, -, + =, ==,>, in, is not, and]:
# Correct wording i = i +. 1 submitted + =. 1 X = X * 2 -. 1 hypot2 = X * X + Y * Y C = (A + B) * (A - B) # Not recommended wording i = i + 1'd submitted +. 1 = X = X * 2 -. 1 hypot2 = Y * X * X + Y C = (A + B) * (ab &)
2, the parameter list in the function ,, then there must be space
# Correct wording DEF Complex (Real, imag): Pass # not recommended wording DEF Complex (Real, imag): Pass
3, the function parameter list, the default value is equal on both sides avoiding spaces
# Correct wording from spam (Ham [. 1], {eggs: 2 }) # deprecated wording spam (ham [1], { eggs: 2})
4, after the left bracket, do not add extra spaces before the closing parenthesis
# Correct wording from spam (Ham [. 1], {eggs: 2 }) # deprecated wording spam (ham [1], { eggs: 2})
5, before the left parenthesis dictionary objects do extra spaces
# Correct wording dict [ ' Key ' ] = List [index] # is not recommended wording dict [ ' Key ' ] = List [index]
6, extra space is not aligned assignment and use of
# Correct wording X. 1 = Y = 2 long_variable =. 3 # Not recommended wording X. 1 = Y = 2 long_variable =. 3
7, do not commas, semicolons, colons spaces in front of, but should be added (except at the end) behind them
Yes: if x == 4: print x, y x, y = y, x
No: if x == 4 : print x , y x , y = y , x