According to the own nomenclature conventions Python Enhancement Proposal 8, some concerns include:
Avoid certain names
Never use the characters 'l', 'O', or 'I' as variable names because in some sources they are indistinguishable from the numbers one and zero.
Package and module names
Modules should have small names, these written in lower case in full.
Ex: package
Class names
Class names have the first letter of each uppercase word (Camelcase).
Ex: Nomedeumaclasse
Function names and methods
Function and method names should be in lower case letters, with words separated by underscores as useful for readability.
Ex: function name
Note: the mixed case (all uppercase initials except the first) is allowed only in contexts where this is already the predominant style, to maintain compatibility with previous versions.
Constants
Constants are usually defined at a module level and written in uppercase letters with underscores separating words. Examples include MAX_OVERFLOW and TOTAL.
Variable names and function parameters and methods
They usually follow the same rule of function, and should be in lower case letters, with words separated by underscores as useful for readability.
Note: Use self as the first parameter of a method.
Ex: method_name(self):
Identation
Identation should be done using four spaces per level.
Blank lines
Blank lines are recommended to separate functions and class definitions (two lines), plus method definitions (one line).
Blanks
White space should be used to separate mathematical, binary, comparison and assignment operators from other elements.
Ex:
if variavel == False:
print 2 * 3
You should avoid using blank spaces between parentheses and parameters in the declaration of a function, as well as between a function call and the first parenthesis of its argument list.
Ex: function(first parameter, second parameter)
William, could you put examples for all cases? I think it would look better to illustrate! Abs
– Carlos Cinelli
I think it’s now more complete! Abs
– Guilherme Agostinelli
Only one correction: PEP-8 says nothing about spaces between arguments of a function - only object spaces between parentheses (or keys) and parameters. If you look at the examples of PEP, however, you will notice that there are always spaces between the arguments (fortunately!), as in
spam(ham[1], {eggs: 2})
.– brandizzi
Fixed! Thanks for the reminder (=
– Guilherme Agostinelli