This content originally appeared on DEV Community and was authored by sarvsav
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.
This content originally appeared on DEV Community and was authored by sarvsav
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
sarvsav | Sciencx (2024-10-18T21:14:01+00:00) Day005 – Random posts under TIL. Retrieved from https://www.scien.cx/2024/10/18/day005-random-posts-under-til/
" » Day005 – Random posts under TIL." sarvsav | Sciencx - Friday October 18, 2024, https://www.scien.cx/2024/10/18/day005-random-posts-under-til/
HARVARDsarvsav | Sciencx Friday October 18, 2024 » Day005 – Random posts under TIL., viewed ,<https://www.scien.cx/2024/10/18/day005-random-posts-under-til/>
VANCOUVERsarvsav | Sciencx - » Day005 – Random posts under TIL. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/18/day005-random-posts-under-til/
CHICAGO" » Day005 – Random posts under TIL." sarvsav | Sciencx - Accessed . https://www.scien.cx/2024/10/18/day005-random-posts-under-til/
IEEE" » Day005 – Random posts under TIL." sarvsav | Sciencx [Online]. Available: https://www.scien.cx/2024/10/18/day005-random-posts-under-til/. [Accessed: ]
rf:citation » Day005 – Random posts under TIL | sarvsav | Sciencx | https://www.scien.cx/2024/10/18/day005-random-posts-under-til/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.