Skip to content

Instantly share code, notes, and snippets.

@ashwin
Created May 3, 2012 22:52
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 ashwin/2590145 to your computer and use it in GitHub Desktop.
Save ashwin/2590145 to your computer and use it in GitHub Desktop.
Adding function attributes in Python
def foo():
return foo.x
print( foo() ) # AttributeError: 'function' object has no attribute 'x'
foo.x = 10
print( foo.x ) # 10
print( foo() ) # 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment