Topics
- Best practices in Python
1. Best practices in Python
Read this article on Writing Python Scripts in modern way by Bryson Meiling and it is very insightful. In summary,
- use pyproject.toml instead of requirements.txt.
- Use uv for virtual environment.
- Use type hints.
- Add raises section to the docstrings.
- Use pydantic models.
- Use linter and formatter like Ruff.
- Use pytest.
- Use orjson instead of json.
- Always use fstring.
- Use pathlib instead of os.path.
- Use Typer instead of argparse.
Top comments (0)