claudegoodies
Skill

python-patterns

From affaan-m

Patrones idiomáticos de Python, estándares PEP 8, type hints y buenas prácticas para construir aplicaciones Python robustas, eficientes y mantenibles.

Documents Python idioms, PEP 8 style, type hints, error handling and context manager patterns for reference.

Use it when

  • Writing new Python code needing PEP 8/type hint conventions
  • Reviewing Python code for idiomatic patterns
  • Refactoring existing Python modules
  • Designing Python package/module structure

Skip it if

  • You already follow PEP 8 and type hints fluently
  • It's a static reference doc, not a tool or automated check
  • Only Python-specific, no value for other languages

Facts

Repository
affaan-m/ECC
Status
Actively maintained
Last commit

Source preview

The instructions Claude Code reads when this skill runs.

# Patrones de Desarrollo Python

Patrones idiomáticos de Python y buenas prácticas para construir aplicaciones robustas, eficientes y mantenibles.

## Cuándo Activar

- Escribir código Python nuevo
- Revisar código Python
- Refactorizar código Python existente
- Diseñar paquetes/módulos Python

## Principios Fundamentales

### 1. La Legibilidad Cuenta

Python prioriza la legibilidad. El código debe ser obvio y fácil de entender.

```python
# Bien: Claro y legible
def get_active_users(users: list[User]) -> list[User]:
    """Retorna solo los usuarios activos de la lista proporcionada."""
    return [user for user in users if user.is_active]


# Mal: Inteligente pero confuso
def get_active_users(u):
    return [x for x in u if x.a]
```

### 2. Explícito es Mejor que Implícito

Evitar la magia; ser claro sobre lo que hace el código.

```python
# Bien: Configuración explícita
import logging

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)

# Mal: Efectos secundarios ocultos
import some_module
some_module.setup()  # ¿Qué hace esto?
```

### 3. EAFP - Es Más Fácil Pedir Perdón que Permiso

Python prefiere el manejo de excepciones sobre verificar condiciones.

```python
# Bien: Estilo EAFP
def get_value(dictionary: dict, key: str) -> Any:
    try:
        return dictionary[key]
    except KeyError:
        return default
View full source on GitHub →

Other skills