jensklaren/python icon
public
Published on 7/15/2025
Python Best Practices

Rules

rules:

  • Always annotate Python functions with parameter and return types
  • Write Google style docstrings for classes and functions
  • Prefer list comprehensions over map() and filter()
  • Handle exceptions specifically instead of using bare except clauses
  • Use snake_case for variables and function names
  • Always use type hints for function parameters and returns
  • Document functions and classes with clear docstrings
  • Prefer pandas vectorized operations over loops for data manipulation
  • Use pathlib instead of os.path for file operations
  • Structure code to be reproducible and deterministic
  • Cache intermediate results of expensive computations
  • Include meaningful comments for complex algorithms