This article has been dead for over three months
You
def static_vars(**kwargs):
"""Decorator for creating function object attributes"""
def T(f):
f.__dict__.update(kwargs)
return f
return T
@static_vars(s=0, p=1, cache=[])
def my_func(x):
my_func.cache.append(x)
my_func.s += x
my_func.p *= x
return my_func.s, my_func.p, my_func.cache
print(my_func(1))
print(my_func(2))
print(my_func(3))
print(my_func(4))