Python Engineering Standards at CirrusLabs
-
Code Formatting:
- Use 4 spaces for indentation.
- Use snake_case for variable and function names.
- Use CAPITAL_SNAKE_CASE for constants.
- Limit lines to 79 characters.
-
Naming Conventions:
- Use descriptive names for variables, functions, and classes.
- Avoid using single-letter variable names except for iterators (e.g.,
i
,j
,k
).
-
Comments:
- Use comments to explain complex algorithms or to provide context where necessary.
- Use docstrings to document functions, classes, and modules.
-
Error Handling:
- Use try-except blocks for handling exceptions.
- Catch specific exceptions rather than using a generic
except:
clause. - Always include a meaningful message when raising exceptions.
-
Best Practices:
- Use list comprehensions and generator expressions instead of loops where possible.
- Use context managers (
with
statement) for resource management. - Follow the PEP8 style guide for Python code.