Static Variables

Emile van Sebille emile at fenx.com
Wed Apr 3 08:07:59 EST 2002


Andrew Dalke
> What I didn't think about was Gerhard's "counter.cnt" mechanism.
> (My mind's still stuck in the 1.4 days :)  I really like that, and
> think I'll use it more often in the future.
>

Was this a post?  If so, I couldn't locate it.  Does it do something
like:

>>> def counter():
...     try: counter.cnt
...     except: counter.cnt= 0
...     counter.cnt += 1
...     return counter.cnt
...
>>> counter()
1
>>> counter()
2

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list