There is a questions asking how to simulate static variables in python.
Also, on the web one can find many different solutions to create static variables. (Though I
An ill-advised alternative:
You can also use the side-effects of the definition time evaluation of function defaults:
def func(initial=0, my_static=[])
if not my_static:
my_static.append(initial)
my_static[0] += 1
return my_static[0]
print func(0), func(0), func(0)
Its really ugly and easily subverted, but works. Using global would be cleaner than this, imo.