Top "Python-decorators" questions

In Python, decorators are functions that conveniently alter functions, methods or classes using a special syntax.

How to skip a pytest using an external fixture?

Background I am running a py.test with a fixture in a conftest file. You can see the code below(…

python decorator pytest python-decorators
How can I implement a custom error handler for all HTTP errors in Flask?

In my Flask app, I can easily expand the list of errors handled by a single custom error handler by …

python error-handling flask python-decorators
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 to write Flask decorator with request?

I am not sure why following decorator[validate_request] doesn't work. What is correct way to write such validation decorator? …

python flask python-decorators
python wrapper function taking arguments inside decorator

I am trying to write python decorators and I am having problems understanding how the internal wrapper takes arguments. I …

python decorator python-decorators
Applying a decorator to an imported function?

I want to import a function: from random import randint and then apply a decorator to it: @decorator randint I …

python function decorator python-decorators
decorator to set attributes of function

I want different functions to be executable only if the logged in user has the required permission level. To make …

python attributes decorator python-decorators function-attributes
python decorator TypeError missing 1 required positional argument

I'm trying to write a decorator to repeat an erroring function N times with increasingly sleeping times in between. This …

python python-decorators
Possible to create a @synchronized decorator that's aware of a method's object?

I'm trying to create a @synchronized wrapper that creates one Lock per object and makes method calls thread safe. I …

python decorator python-decorators
Numpy vectorize as a decorator with arguments

I tried to vectorize (agreed, not the most efficient way to do it, but my question is rather on the …

python numpy decorator python-decorators