Top "Decorator" questions

Decorator is an object-oriented design pattern that allows adding behavior to existing classes in a dynamic fashion.

Get the name of a decorated function?

here is my decorator: def check_domain(func): def wrapper(domain_id, *args, **kwargs): domain = get_object_or_None(Domain, …

python django decorator
How to strip decorators from a function in Python

Let's say I have the following: def with_connection(f): def decorated(*args, **kwargs): f(get_connection(...), *args, **kwargs) return …

python decorator
Decorator pattern versus sub classing

I can solve the problem of adding functionality by adding sub classing then why should I use decorator pattern what's …

design-patterns decorator
Decorator classes in Python

I want to construct classes for use as decorators with the following principles intact: It should be possible to stack …

python decorator
Python Class Based Decorator with parameters that can decorate a method or a function

I've seen many examples of Python decorators that are: function style decorators (wrapping a function) class style decorators (implementing __init__, __…

python function methods arguments decorator
Factory method for objects - best practice?

This is a question regarding the best practice for creating an instance of a class or type from different forms …

python coding-style decorator class-method factory-method
Function acting as both decorator and context manager in Python?

This might be pushing things a little too far, but mostly out of curiosity.. Would it be possible to have …

python decorator contextmanager
Introspection to get decorator names on a method?

I am trying to figure out how to get the names of all decorators on a method. I can already …

python decorator introspection
Auto-register class methods using decorator

I want to be able to create a python decorator that automatically "registers" class methods in a global repository (with …

python oop design-patterns decorator metaclass
Strategy Pattern V/S Decorator Pattern

I just came across two patterns. Strategy Pattern Decorator Strategy Pattern :- Strategy pattern gives several algorithms that can be …

design-patterns decorator strategy-pattern