Skip to content

Instantly share code, notes, and snippets.

@oxnz
Created October 20, 2014 05:19
Show Gist options
  • Save oxnz/1d524a1cf58e0a2b40ad to your computer and use it in GitHub Desktop.
Save oxnz/1d524a1cf58e0a2b40ad to your computer and use it in GitHub Desktop.
python function static variable use decorator
def static_variable(name, val):
def decorate(func):
setattr(func, name, val)
return func
return decorate
@static_variable('static_a', 10)
def test():
print test.a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment