Skip to content

Instantly share code, notes, and snippets.

@iKlsR
Created January 5, 2013 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iKlsR/4458871 to your computer and use it in GitHub Desktop.
Save iKlsR/4458871 to your computer and use it in GitHub Desktop.
decorator example..
# A decorator is a function that takes another function object as an argument
# and returns said function object as a return value..
def addone(func):
"""squares anything passed to it"""
def modfunc(n):
func(n)
print '> and squared it is', n ** 2
return modfunc
@addone
def printx(x):
print '> the original value is', x
if __name__ == '__main__':
printx(5)
print addone.__doc__
@iKlsR
Copy link
Author

iKlsR commented Jan 5, 2013

multiline comments are hideous.. <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment