This repository has examples to help developers understand and improve their Python coding practices.
Related to this, there is a series of Linkedin posts that will be a suitable complement:
- Python Recommended coding practices - part 1: PEP8 explains about PEP8, its name conventions, code layout and linters.
- Python Recommended coding practices - part 2: Clean Code: In this article, I wrote about Python Clean Code practices.
- Python Recommended coding practices - part 3: SOLID Principles: In this article, I wrote about the SOLID principles with Python examples.
- Testing in Python using Pytest and Mock: In this article, I wrote about Pytest and Mock. I discussed basic use, fixtures, markers, parametrization and duration.
- Good Practices for Documenting Python Code: In this article I wrote about documentation in Python, including Type Hinting and Docstrings. And how to use Sphinx to generate HTML (or other format) documentation from the Docstrings.
Each folder of this project is related to one specific topic:
- .vscode: This folder contain example of VSCode configuration.
- clean_code: This folder contains examples for "Clean Code" principles.
- documenting: This folder contains examples for code documentation.
- pep8: This folder contains examples for PEP8 style guidelines.
- solid: This folder contains examples for SOLID principles.
- testing: This folder contains examples for testing, including Pytest examples and using mocking.
- .gitignore: This file contain patterns for ignoring files and folders on your local computer to GitHub.
- .pre-commit-config.yaml: This file containes configuration for all the pre-commit tasks.
git clone https://github.com/claudiosw/python-best-practices.git
python -m venv venv
venv\Scripts\activate
source venv/bin/activate
pip install -r requirements.txt
pre-commit install
sphinx-apidoc -f -o docs/source .
make clean html
make html
You can see the documentation of this project generated for Sphinx in here.