Skip to content

Instantly share code, notes, and snippets.

@stober
Created August 30, 2012 17:41
Show Gist options
  • Save stober/3534845 to your computer and use it in GitHub Desktop.
Save stober/3534845 to your computer and use it in GitHub Desktop.
A workaround for "static" variables in Python functions.
#!/usr/bin/env python
'''
@author jstober
'''
def test_static(static=[0]):
static[0] += 1
return static[0]
print test_static() # 1
print test_static() # 2
print test_static() # 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment