Skip to content
Back to skills

Python Decorators Advanced

ASecurity

Use when implementing advanced Python decorators.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 10, 2026
ai-agentspythonapi

Works with

  • api

Security analysis

A100/100

Scanned September 10, 2026

npx -y skills add LoopyLuci/Skills --skill python-decorators-advanced --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python Decorators Advanced?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Python Decorators Advanced
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/loopyluci-python-decorators-advanced/badge)](https://www.skillsdirectory.com/skills/loopyluci-python-decorators-advanced)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: python-decorators-advanced
description: "Use when implementing advanced Python decorators."
version: 1.0.0
author: Hermes Agent
license: MIT
metadata:
  hermes:
    tags: [python, decorators, functools, wraps, class-decorators]
    related_skills: [python-async-patterns, clean-code-principles, cross-thread-async]
---

# Advanced Python Decorators

Implementing advanced Python decorators — from parameterized decorators through class decorators, decorators with arguments, and stacked patterns.

## When to Use

- Building reusable cross-cutting concerns
- Implementing caching, retry, timing decorators
- Building DSL-like APIs with decorators

## Decorator Patterns

```python
from functools import wraps
import time

def retry(max_attempts=3, delay=1):
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            for i in range(max_attempts):
                try: return func(*args, **kwargs)
                except Exception as e:
                    if i == max_attempts - 1: raise
                    time.sleep(delay)
            return None
        return wrapper
    return decorator

def timer(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        print(f"{func.__name__}: {time.time()-start:.3f}s")
        return result
    return wrapper
```

## Verification Checklist

- [ ] @wraps used to preserve metadata
- [ ] Decorator factory with arguments pattern
- [ ] Stacking decorators in correct order
- [ ] Class-based decorators with __call__
- [ ] Async decorator support

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.