2,599
edits
Efernandez (talk | contribs) |
Efernandez (talk | contribs) (→Naming) |
||
Line 54: | Line 54: | ||
For more information see [https://www.python.org/dev/peps/pep-0008/#imports imports] | For more information see [https://www.python.org/dev/peps/pep-0008/#imports imports] | ||
== Naming == | == Naming == | ||
=== Package and module names === | |||
Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged. See [https://www.python.org/dev/peps/pep-0008/#package-and-module-names package and module names] for more information. | |||
=== Class names === | |||
Class names should normally use the '''CapWords''' convention. See [https://www.python.org/dev/peps/pep-0008/#class-names class-names] for more information. | |||
=== Function and Variable Names === | |||
Functions and variable names should use '''sneake_case'''. | |||
=== Global variables === | |||
Global variables should follow the same convention as functions. | |||
=== Function and Method Arguments === | |||
*Always use '''self''' for the first argument to instance methods. | |||
*Always use '''cls''' for the first argument to class methods. | |||
=== Method Names and Instance Variables === | |||
* Use the function naming rules: lowercase with words separated by underscores as necessary to improve readability. | |||
* Use one leading underscore only for non-public methods and instance variables. | |||
=== Constants === | |||
Constants are usually defined on a module level and written in all capital letters with underscores separating words. | |||
== Comments == | == Comments == |