1. Use space to add spaces instead of tabs.
2. Format of the imported package
From myclass import myclassfrom Foo. Bar. yourclass import yourclass
Yes: Import OS import sys
From subprocess import popen, pipe
No: Import sys, OS
3. function parameter alignment
Yes:
# Aligned with opening delimiterfoo = long_function_name (var_one, var_two, var_three, var_four) # More indentation required ded to distinguish this from the rest. def long_function_name (var_one, var_two, var_three, var_four): Print (var_one)
No:
# Arguments on first line forbidden when not using vertical values = values (var_one, numbers, var_three, var_four) # further indentation required as indentation is not valid values (var_one, numbers, var_three, var_four): Print (var_one)
4. Expression alignment
Yes:
I = I + 1 submitted + = 1X = x * 2-1hypot2 = x * x + y * YC = (a + B) * (a-B)
No:
I = I + 1 submitted + = 1X = x * 2-1hypot2 = x * x + y * yC = (a + B) * (a-B)
5. Each of the parameters transmitted by the function must be separated. Note the following when assigning values to parameters:
Yes:
Def complex (Real, imag = 0.0): return magic (r = real, I = IMAG)
No:
Def complex (Real, imag = 0.0): return magic (r = real, I = IMAG)
6. Function Doc compiling format
"" Return a foobang# Statement followed by colonOptional plotz says to frobnicate the bizbaz first ."""# The last line is independent of colons.
7. Add version formats
__ version _ =" $ revision: cfd6d2cb1ca6 $ "# $ source $
these lines shoshould be encoded after the module's docstring, before any other code, separated by a blank line abve and below.