This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tools:style_guides:python [2015/05/26 11:28] 127.0.0.1 external edit |
tools:style_guides:python [2020/05/20 13:20] msamso [Python Language Rules] |
||
---|---|---|---|
Line 4: | Line 4: | ||
==== Overview ==== | ==== Overview ==== | ||
- | Python is the main language used in Autosubmit. This style guide is a list of //dos// and // | + | Python is the main language used in Autosubmit. This style guide is a list of //dos// and // |
- | In order to format the code correctly you can use [[http://google-styleguide.googlecode.com/svn/trunk/ | + | In order to format the code correctly you can use [[https://google.github.io/styleguide/ |
Line 13: | Line 13: | ||
* Use public variables for accessing or setting data where accessor or setter methods would be trivial, avoiding the extra cost of function calls in Python. | * Use public variables for accessing or setting data where accessor or setter methods would be trivial, avoiding the extra cost of function calls in Python. | ||
- | * Use properties for accessing or setting data where you would normally have used simple, lightweight accessor or setter methods. More about properties [[http://google-styleguide.googlecode.com/svn/trunk/ | + | * Use properties for accessing or setting data where you would normally have used simple, lightweight accessor or setter methods. More about properties [[https://google.github.io/styleguide/ |
* Use accessor or setter methods where you would require heavy processing. | * Use accessor or setter methods where you would require heavy processing. | ||
Line 20: | Line 20: | ||
* Run [[http:// | * Run [[http:// | ||
+ | * **Tabnanny: | ||
+ | * Command line: python -m tabnanny -v file.py | ||
+ | * Code: | ||
+ | |||
+ | import tabnanny | ||
+ | tabnanny.check(' | ||
+ | |||
Line 28: | Line 35: | ||
* Indent your code blocks with 4 spaces. | * Indent your code blocks with 4 spaces. | ||
* Two blank lines between top-level definitions, | * Two blank lines between top-level definitions, | ||
- | * Use doc strings for module, function, method, class and attributes comments in the format explained [[http://google-styleguide.googlecode.com/svn/trunk/ | + | * Use doc strings for module, function, method, class and attributes comments in the format explained [[https://google.github.io/styleguide/ |
* If a class inherits from no other base classes, explicitly inherit from object. This also applies to nested classes. | * If a class inherits from no other base classes, explicitly inherit from object. This also applies to nested classes. | ||
* Use TODO comments for code that is temporary, a short-term solution, or good-enough but not perfect. | * Use TODO comments for code that is temporary, a short-term solution, or good-enough but not perfect. | ||
* Imports should be on separate lines. | * Imports should be on separate lines. | ||
- | * Refer to http://google-styleguide.googlecode.com/svn/trunk/ | + | * Refer to https://google.github.io/styleguide/ |