I think the answer is no, but I can't seem to find a definitive claim. I have the following situation;
def decorated_function(function):
@functools.wraps(function)
def my_function():
print "Hello %s" % function.__name__
return my_function
for attr, value in dct.iteritems():
dct[attr] = decorated_function(value)
And what I really want is something like;
def my_function(function):
print "Hello %s" % function.__name__
for attr, value in dct.iteritems():
dct[attr] = functools.wraps(my_function, value)
to remove the confusing shell of decorated_function. Are decorators only possible to apply when the function is defined?