Skip to content

Instantly share code, notes, and snippets.

@Susensio
Susensio / static_variable_decorator.py
Created April 27, 2020 12:39
Python static variable decorator for functions
# Source: https://stackoverflow.com/questions/279561/what-is-the-python-equivalent-of-static-variables-inside-a-function/279586#279586
def static_vars(**kwargs):
def decorate(func):
for k in kwargs:
setattr(func, k, kwargs[k])
return func
return decorate