Follow PEP 8 — Python's official style guide. Use snakecase for functions and variables, PascalCase for classes, and UPPERSNAKECASE for constants. Keep lines under 79-88 characters. Use a linter like Ruff or flake8 to enforce style automatically. Virtual Environments & Dependencies Always use virtual environments (python -m venv .venv) to isolate project dependencies. Pin exact versions in requirements.txt for reproducibility. Use Poetry or pip-tools for advanced dependency management. Pythonic Patterns Write Pythonic code: use list comprehensions over manual loops, context managers (with) for resource handling, and f-strings for formatting. Add type hints to function signatures for clarity and editor support. Use pathlib.Path instead of os.path for file operations.
Key Takeaways
Follow PEP 8: snakecase for functions, PascalCase for classes.
Always use virtual environments to isolate project dependencies.
Add type hints for function signatures to improve readability.
Use context managers (with statement) for files, connections, and locks.