Appearance
Python style guide
It is very useful to respect some norms and standards in your code, for various reasons, such as:
- Better code readability: it becomes easier to write and to read the code
- Better maintainability: having a more readable code is easier to modify if necessary
- Better performances management: coding conventions allow a better optimization of the resources
In general, we refer to the style guidelines for Python defined in PEP 8.
We also recommend to use Flake8, which is a tool for style guide enforcement.
You will find a file named CONVENTIONS.md in the various provided boilerplates. Hereafter are some of the rules we respect:
Column limit: 120
We recommend a column limit of 120 characters.
Whitespace
We make an exception to PEP8 by preferring whitespace around all operators, regardless of priority. We find this approach to be both readable and consistent with rules applied in JavaScript.
YES:
python
END_OF_DAY = 3600 * 24 - 1
FOO = (1 + 2) * 3NO:
python
END_OF_DAY = 3600*24 - 1
FOO = (1+2) * 3Use single quotes
We recommend that ordinary string literals are delimited with single quotes ( ' ), rather than double quotes ( " ).
Exception: use double quotes ( " ) if the string contains a single quote ( ' ).
For example:
python
users = List(cls, part_name=String(description='Au moins trois lettres'), description="Utilisateurs d'Azure")
name = 'all_azure_users'Next chapter
This clarified, we can go the next chapter, dealing with tools and technologies.