Does anyone else use this little idiom?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sun Feb 3 16:56:18 EST 2008


On Sun, 03 Feb 2008 05:33:16 -0800, Ivan Illarionov wrote:

> Plain Python function are very often more powerful than classes:
> 
>>>> def go(count):
> ...   if not hasattr(go, 'count'):
> ...     go.count = count
> ...   if go.count <= 0:
> ...     del go.count
> ...     return False
> ...   go.count -= 1
> ...   return True
> ...
>>>> while go(3):
> ...   print 'hello'
> ...
> hello
> hello
> hello
>>>>

Please try:

while go(3):
    while go(3):
        print 'Think about it...'

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list