Last active
December 24, 2015 08:29
-
-
Save pratikmallya/6771130 to your computer and use it in GitHub Desktop.
This piece of code is what I'm using to clarify certain function-related concepts in Python, especially those relating to decorators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test decorator functionality in Python | |
def log(F): | |
def print_args(*args, **kwargs): | |
print args, kwargs | |
return print_args | |
@log | |
def holy_smokes(a, b, c): | |
print a + b + c | |
if __name__ == "__main__": | |
holy_smokes(1,2,3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice Resources on Decorators:
http://www.siafoo.net/article/68
http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/