User Tools

Site Tools


tools:style_guides:python

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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] (current)
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 //don'ts// for Autosubmit code based on the [[http://google-styleguide.googlecode.com/svn/trunk/pyguide.html|Google's Python style guide]].+Python is the main language used in Autosubmit. This style guide is a list of //dos// and //don'ts// for Autosubmit code based on the [[https://google.github.io/styleguide/pyguide.html|Google's Python style guide]].
  
-In order to format the code correctly you can use [[http://google-styleguide.googlecode.com/svn/trunk/google_python_style.vim|the settings file for Vim]] created by Google.+In order to format the code correctly you can use [[https://google.github.io/styleguide/google_python_style.vim|the settings file for Vim]] created by Google.
  
  
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/pyguide.html?showone=Properties#Properties|here]].+  *  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/pyguide.html#Properties|here]].
   *  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://www.pylint.org/|pylint]] over the code   *  Run [[http://www.pylint.org/|pylint]] over the code
 +  *  **Tabnanny:** Tool to check tabs [[https://docs.python.org/3/library/tabnanny.html|tabnanny]]:
 +    * Command line: python -m tabnanny -v file.py
 +    * Code:
 +
 +      import tabnanny
 +      tabnanny.check('file.py')
 +
  
  
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, one blank line between method definitions   *  Two blank lines between top-level definitions, one blank line between method definitions
-  *  Use doc strings for module, function, method, class and attributes comments in the format explained [[http://google-styleguide.googlecode.com/svn/trunk/pyguide.html?showone=Comments#Comments|here]] and in-line explanations using "#" for tricky or non-obvious operations.+  *  Use doc strings for module, function, method, class and attributes comments in the format explained [[https://google.github.io/styleguide/pyguide.html#Comments|here]] and in-line explanations using "#" for tricky or non-obvious operations.
   *  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/pyguide.html?showone=Naming#Naming for naming rules and conventions.+  *  Refer to https://google.github.io/styleguide/pyguide.html#Naming for naming rules and conventions.
  
tools/style_guides/python.1432639699.txt.gz ยท Last modified: 2017/10/30 08:37 (external edit)