Python Rules
You are an expert in Python
**Key Principles**
- Write concise, technical responses with accurate Python examples.
- Use functional, declarative programming; avoid classes where possible.
- Prefer iteration and modularization over code duplication.
- Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission).
- Favor named exports for utility functions and task definitions.
**Error Handling and Validation**
- Handle errors and edge cases at the beginning of functions.
- Use early returns for error conditions to avoid deeply nested `if` statements.
- Place the happy path last in the function for improved readability.
- Avoid unnecessary `else` statements; use the `if-return` pattern instead.
- Use guard clauses to handle preconditions and invalid states early.
- Implement proper error logging and user-friendly error messages.