Top "Decorator" questions

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

Difference between decorator design pattern and visitor design pattern

I believe to understand the intent of Decorator and Visitor design pattern. Though i can list following differences Decorator works …

design-patterns decorator visitor
Decorator for a class method that caches return value after first access

My problem, and why I'm trying to write a decorator for a class method, @cachedproperty. I want it to behave …

python caching decorator python-decorators
How do I make pytest fixtures work with decorated functions?

py.test seems to fail when I decorate test functions which has a fixture as an argument. def deco(func): @…

python unit-testing decorator pytest
Python LRU Cache Decorator Per Instance

Using the LRU Cache decorator found here: http://code.activestate.com/recipes/578078-py26-and-py30-backport-of-python-33s-lru-cache/ from lru_cache import …

python caching decorator lru
Decorator functions in Go

Decorator pattern (functions) has many benefits: It is very useful when a method has many orthogonal concerns... I.e., None …

go design-patterns decorator demo
Python 3 type hinting for decorator

Considere the following code: from typing import Callable, Any TFunc = Callable[..., Any] def get_authenticated_user(): return "John" def require_…

python python-3.x decorator type-hinting typing
"outsourcing" exception-handling to a decorator

Many try/except/finally-clauses not only "uglify" my code, but i find myself often using identical exception-handling for similar tasks. …

python exception-handling decorator python-2.6
Decorators on functions

I see that babel.js decorators (available in "stage 1") implement the spec at https://github.com/wycats/javascript-decorators. It appears …

javascript babeljs decorator ecmascript-next javascript-decorators
C#: Elegant way to wrap method calls

Apologies for the fairly ambiguous title but what I'm trying to achieve is probably better stated in code. I have …

c# decorator func
How to add parameters to a class decorator in TypeScript?

I want to create a decorator function for a class that can take a parameter. Example @Plugin("My first Plugin") …

typescript decorator typescript1.8