Antoon Pardon <antoon.par...@rece.vub.ac.be>: > def foo() > foo.attr > > changes nothing about foo.attr being globally accessible.
I don't know why global accessibility is such a problem. Anyway, in practice I handle such "static" variables as module globals. If you want a more puristic solution, you could do: def _make_f(): x = 0 def f(): nonlocal x x += 1 return x return f f = _make_f() print(f()) => 1 print(f()) => 2 print(f()) => 3 Marko -- https://mail.python.org/mailman/listinfo/python-list