Skip to content

Instantly share code, notes, and snippets.

@j2labs
Created April 26, 2012 19:44
Show Gist options
  • Save j2labs/2502467 to your computer and use it in GitHub Desktop.
Save j2labs/2502467 to your computer and use it in GitHub Desktop.
abusing python functions
>>> def foo():
... foo.x = 5
... foo.get = lambda: foo.x
... def set(x):
... foo.x = x
... foo.set = set
...
>>> foo()
>>> foo.get()
5
>>> foo.set(3)
>>> foo.get()
3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment