python-expert
Python development best practices and advanced patterns
When & Why to Use This Skill
This Claude skill acts as a senior Python architect and developer, providing comprehensive guidance on modern Python development. It ensures code quality by enforcing PEP 8 standards, implementing advanced design patterns, and utilizing the latest language features like structural pattern matching and type hints. By integrating best practices for error handling, testing with pytest, and standardized project structuring, it helps developers build maintainable, efficient, and production-ready Python applications.
Use Cases
- Refactoring legacy Python scripts: Automatically upgrade older codebases to use modern features such as f-strings, pathlib, and dataclasses for better readability and performance.
- Standardizing project architecture: Generate a professional project boilerplate including src/ layout, pyproject.toml configuration, and automated testing directories.
- Implementing robust error handling: Design sophisticated exception management systems and logging strategies to improve application reliability and debugging.
- Developing high-coverage test suites: Create comprehensive unit tests and fixtures using pytest to ensure code integrity and facilitate continuous integration.
- Optimizing resource management: Apply advanced patterns like context managers and generators to handle file I/O and large data streams efficiently.
| name | python-expert |
|---|---|
| description | Python development best practices and advanced patterns |
Python Expert Skill
When working with Python code, apply these advanced patterns and best practices:
Code Style
- Follow PEP 8 guidelines
- Use type hints for function signatures
- Prefer f-strings for string formatting
- Use meaningful variable and function names
Modern Python Features
- Use dataclasses for data containers
- Prefer pathlib over os.path
- Use context managers for resource management
- Leverage generators for memory efficiency
- Use structural pattern matching (Python 3.10+)
Error Handling
- Use specific exception types
- Provide meaningful error messages
- Log errors appropriately
- Consider using Result types for expected failures
Testing
- Write unit tests with pytest
- Use fixtures for test setup
- Mock external dependencies
- Aim for high test coverage
Project Structure
project/
├── src/
│ └── package/
│ ├── __init__.py
│ └── module.py
├── tests/
│ └── test_module.py
├── pyproject.toml
└── README.md
Packaging
- Use pyproject.toml for configuration
- Define clear dependencies
- Use semantic versioning