Top "Decorator" questions

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

Is there a decorator to simply cache function return values?

Consider the following: @property def name(self): if not hasattr(self, '_name'): # expensive calculation self._name = 1 + 1 return self._name …

python caching decorator memoization
Understand the "Decorator Pattern" with a real world example

I was studying the Decorator Pattern as documented in GOF. Please, help me understand the Decorator Pattern. Could someone give …

decorator design-patterns
How do the Proxy, Decorator, Adapter, and Bridge Patterns differ?

I was looking at the Proxy Pattern, and to me it seems an awful lot like the Decorator, Adapter, and …

design-patterns decorator bridge proxy-pattern
Why does @foo.setter in Python not work for me?

So, I'm playing with decorators in Python 2.6, and I'm having some trouble getting them to work. Here is my class …

python decorator new-style-class
How to implement a typescript decorator?

TypeScript 1.5 now has decorators. Could someone provide a simple example demonstrating the proper way to implement a decorator and describe …

typescript decorator
What are some common uses for Python decorators?

While I like to think of myself as a reasonably competent Python coder, one aspect of the language I've never …

python decorator
decorators in the python standard lib (@deprecated specifically)

I need to mark routines as deprecated, but apparently there's no standard library decorator for deprecation. I am aware of …

python decorator deprecated
How to create abstract properties in python abstract classes

In the following code, I create a base abstract class Base. I want all the classes that inherit from Base …

python properties abstract-class decorator
Difference between the Facade, Proxy, Adapter and Decorator design patterns?

What is the difference between the Facade, Proxy, Adapter, and Decorator design patterns? I have never read a clear explanation, …

design-patterns proxy adapter decorator facade
What's the '@' (at symbol) in the Redux @connect decorator?

I am learning Redux with React and stumbled upon this code. I am not sure if it is Redux specific …

javascript reactjs decorator redux