Skip to content

Instantly share code, notes, and snippets.

@apleonhardt
Created August 16, 2011 14:38
Show Gist options
  • Save apleonhardt/1149232 to your computer and use it in GitHub Desktop.
Save apleonhardt/1149232 to your computer and use it in GitHub Desktop.
Well.
def decorated(func):
def r_func(*args, **kwargs):
print "Decorated call."
return func(*args, **kwargs)
return r_func
@decorated
def double(x):
return 2 * x
if __name__ == "__main__":
print(double(2)) # -> Decorated call.
# -> 4
double_undec = double.func_closure[0].cell_contents
print(double_undec(2)) # -> 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment