Here's an example of how to do this:
classMyDec(object):def __init__(self,flag):self.flag = flag
def __call__(self, original_func):
decorator_self =selfdef wrappee(*args,**kwargs):print'in decorator before wrapee with flag ',decorator_self.flag
original_func(*args,**kwargs)print'in decorator after wrapee with flag ',decorator_self.flag
return wrappee
@MyDec('foo de fa fa')def bar(a,b,c):print'in bar',a,b,c
bar('x','y','z')
Prints:
in decorator before wrapee with flag foo de fa fa
in bar x y z
in decorator after wrapee with flag foo de fa fa