← ClaudeAtlas

python-style-guidelisted

Comprehensive Python programming guidelines based on Google's Python Style Guide. Use when Claude needs to write Python code, review Python code for style issues, refactor Python code, or provide Python programming guidance. Covers language rules (imports, exceptions, type annotations), style rules (naming conventions, formatting, docstrings), and best practices for clean, maintainable Python code.
aiskillstore/marketplace · ★ 329 · Code & Development · score 82
Install: claude install-skill aiskillstore/marketplace
# Python Style Guide Comprehensive guidelines for writing clean, maintainable Python code based on [Google's Python Style Guide](https://google.github.io/styleguide/pyguide.html). ## Core Philosophy **BE CONSISTENT.** Match the style of the code around you. Use these guidelines as defaults, but always prioritize consistency with existing code. ## Language Rules ### Imports Use `import` statements for packages and modules only, not for individual classes or functions. **Yes:** ```python from doctor.who import jodie import sound_effects.utils ``` **No:** ```python from sound_effects.utils import EffectsRegistry # Don't import classes directly ``` #### Import Formatting - Group imports: standard library, third-party, application-specific - Alphabetize within each group - Use absolute imports (not relative imports) - One import per line (except for multiple items from `typing` or `collections.abc`) ```python # Standard library import os import sys # Third-party import numpy as np import tensorflow as tf # Application-specific from myproject.backend import api_utils ``` ### Exceptions Use exceptions appropriately. Do not suppress errors with bare `except:` clauses. **Yes:** ```python try: result = risky_operation() except ValueError as e: logging.error(f"Invalid value: {e}") raise ``` **No:** ```python try: result = risky_operation() except: # Too broad, hides bugs pass ``` ### Type Annotations Annotate all function signatures. Type annotat