Skip to content

Instantly share code, notes, and snippets.

@dmugtasimov
Last active November 14, 2016 14:01
Show Gist options
  • Save dmugtasimov/009e456f167ad4898b3698bcf411caf6 to your computer and use it in GitHub Desktop.
Save dmugtasimov/009e456f167ad4898b3698bcf411caf6 to your computer and use it in GitHub Desktop.
Coding conventions
# Widely adopted coding conventions
* [PEP8](https://www.python.org/dev/peps/pep-0008/)
* [PEP20](https://www.python.org/dev/peps/pep-0020/)
* [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
* [DRY principle](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)
* [Clean Code: A Handbook of Agile Software Craftsmanship](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882)
# Extensions, exceptions and customization
* Preferred order of attributes inside class: class NAMED_CONSTANTS, class data attributes, `__init__()` if present, `__magic_methods__()`, `@properties`, overridden private methods, private methods, overridden public methods, public methods. The order of the methods may be changed in favor of code readability as an exception.
* Only strict dependencies should be used in requirements.txt and setup.py files (meaning: third-party-package==x.y.z, where "x.y.z" is exact version number of python package "third-party-package"). This requirement applies to direct and transitive dependencies (meaning: if "third-party-package" depends on "another-package", then requirements.txt or setup.py should explicitly contain "another-package==a.b.c", where "a.b.c" is a version of "another-package" obtained with `pip freeze` command right after "third-party-package" installation). This will prevent accidental errors on fresh installation due to backward incompatibilities of newest dependencies versions which are installed if strict version requirement is not set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment