Decorator that can take both init args and call args?
Posted
by digitala
on Stack Overflow
See other posts from Stack Overflow
or by digitala
Published on 2010-05-15T07:58:19Z
Indexed on
2010/05/15
8:04 UTC
Read the original article
Hit count: 187
Is it possible to create a decorator which can be __init__
'd with a set of arguments, then later have methods called with other arguments?
For instance:
from foo import MyDecorator
bar = MyDecorator(debug=True)
@bar.myfunc(a=100)
def spam():
pass
@bar.myotherfunc(x=False)
def eggs():
pass
If this is possible, can you provide a working example?
© Stack Overflow or respective owner