Style Guide for Python Code
I love Python; the style guide is a great resource for writing consistent looking code. I particularly enjoyed these:
-
Always use
selffor the first argument to instance methods. -
_single_leading_underscore: weak “internal use” indicator. E.g.from M import *does not import objects whose name starts with an underscore. -
single_trailing_underscore_: used by convention to avoid conflicts with Python keyword -
__double_leading_underscore: when naming a class attribute, invokes name mangling (inside classFooBar,__boobecomes_FooBar__boo). -
Comparisons to singletons like
Noneshould always be done withisoris not, never the equality operators.