Top "Decorator" questions

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

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
Python: Exception decorator. How to preserve stacktrace

I am writing a decorator to apply to a function. It should catch any exception, and then raise a custom …

python exception wrapper decorator
Send Custom message in Django PermissionDenied

I am using django's PermissionDenied to render 403.html whenever the user is not allowed to access any page. There are …

python django views decorator permission-denied
Decorator pattern: Why do we need an abstract decorator?

This question was asked already here, but rather than answering the specific question, descriptions of how the decorator pattern works …

java design-patterns oop decorator
Python Sphinx autodoc and decorated members

I am attempting to use Sphinx to document my Python class. I do so using autodoc: .. autoclass:: Bus :members: While …

python decorator python-sphinx autodoc
Decorator Pattern vs Inheritance with examples

I've been experimenting with the decorator pattern to extend functionality of code you do not want to touch for example …

c# .net design-patterns inheritance decorator
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
What is the best way to do automatic attribute assignment in Python, and is it a good idea?

Instead of writing code like this every time I define a class: class Foo(object): def __init__(self, a, b, …

python attributes decorator