forked from Exa-Networks/exabgp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PEP8
54 lines (36 loc) · 1.95 KB
/
PEP8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
PEP8 is Python coding standard.
http://www.python.org/dev/peps/pep-0008/
This code is not fully following PEP8, we do not enforce/follow the following :
W191 - use space for indentation
I like three space for tabs, others like their code less compact, tabs are just great for that
E101 - indentation using mix of tabs and space
Obviously MUST be followed ... but ONE case : when aligning paramenters data over multiple lines.
The extra line should start with tabs to the point of indentation and finish with space, so the
alignment does not change when tabs spaces are changes (from 1 to 8 for example)
E201 - whitespace after '{'
E202 - whitespace before ')'
E203 - whitespace before ','
E211 - whitespace before '('
E225 - missing whitespace around operator
E231 - E231 missing whitespace after ','
Function should be defined as :
def foo (param1, param2, param3):
and used calling
foo(param1,param2,param3)
This makes search of function definition vs call must easier
This makes the reading of the function interface easier as well
list can be clearer when defined as :
mylist = [ element1 , element2 , element3 ]
E221 - multiple spaces before operator
E272 - for extraneous whitespace around keywords
Sometimes it can make the code more readable to have aligned operation :
mostly if they are on the same line of a single if test
E302 - blank lines
E303 - blank lines
This rule is too rigid, if two class are related, one blank can convey the idea
Three blank can be used to separate code more visibly
E501 - line too long
This is a good coding practice but warning messages to users violate that rule so ignored
in the file with long strings
E701 - multiple statements on one line
As python does not have switch, multiple if lines with only a one action are visually pleasing