Top "Decorator" questions

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

How does the @property decorator work in Python?

I would like to understand how the built-in function property works. What confuses me is that property can also be …

python properties decorator python-decorators python-internals
How to make function decorators and chain them together?

How can I make two decorators in Python that would do the following? @makebold @makeitalic def say(): return "Hello" ...which …

python decorator python-decorators
Creating a singleton in Python

This question is not for the discussion of whether or not the singleton design pattern is desirable, is an anti-pattern, …

python singleton decorator base-class metaclass
Decorators with parameters?

I have a problem with the transfer of variable 'insurance_mode' by the decorator. I would do it by the …

python decorator
Experimental decorators warning in TypeScript compilation

I receive the warning... Experimental support for decorators is a feature that is subject to change in a future release. …

typescript decorator visual-studio-code
How to get method parameter names?

Given the Python function: def a_method(arg1, arg2): pass How can I extract the number and names of the …

python decorator introspection python-datamodel
What does functools.wraps do?

In a comment on this answer to another question, someone said that they weren't sure what functools.wraps was doing. …

python decorator functools
Calling class staticmethod within the class body?

When I attempt to use a static method from within the body of the class, and define the static method …

python decorator static-methods
How to decorate a class?

In Python 2.5, is there a way to create a decorator that decorates a class? Specifically, I want to use a …

python decorator python-2.5
Python decorators in classes

Can one write something like: class Test(object): def _decorator(self, foo): foo() @self._decorator def bar(self): pass This …

python class decorator self