Assuming I have a decorator and a wrapped function like this:
def squared(method):
def wrapper(x, y):
return method(x*x, y*y)
return wrapper
@squared
def sum(x, y):
return x+y
I have other code that would like to call the undecorated version of the sum
function. Is there an import trick that can get me to this unwrapped method? If my code says from some.module.path import sum
then, I get the wrapped version of the sum
method, which is not what I want in this case. (Yes, I know I could break this out into a helper method, but that breaks some of the cleanliness of the pattern I'm going for here.)
I'm okay with adding extra "magic" to the decorator to provide some alternate symbol name (like orig_sum
) that I could then import, I just don't know how to do that.