-
Notifications
You must be signed in to change notification settings - Fork 2
python style guide
The Ladybug Tools Python style guide is the style guide for all Ladybug Tools Python projects. In general, the Ladybug Tools style guide closely follows PEP 8 with some small differences.
Docstrings follow Google's doc stings Style which is a modification of PEP 257.
See Google's Python Style Guide to review the most important rules.
Following the Style Guide is critical for the success of the project and once you get used to it will improve your overall efficiency. Most of the editors already have plugins to help you test your code against PEP8 or even autopep8 your code. Use them! Here is the one for atom.
79 characters with a soft limit of 89 if absolutely necessary. Avoid too deeply nested code by cleverly placing break, continue and return statements.
In case the name is used in solvers (e.g. OpenFOAM) with a different naming convention follow the solver convention.
class Alphat(object):
def internalField(self): # not internal_field
# ...
While PEP8 normally recommends CamelCase for class names, acronyms should be kept in uppercase (HTTPWriter and not HttpWriter). This means all file type objects should be kept in capital letters (ie. EPW and not Epw). More information on this precedents can be found here: https://palletsprojects.com/governance/sourcecode/python-styleguide/