define loop statement?

Jeffrey Schwab jeff at schwabcenter.com
Sat Feb 18 15:33:09 EST 2006


Jeffrey Schwab wrote:

> class Loop:
>     def __init__(self, n):
>         self.n = n
>     def __call__(self):
>         self.n = self.n - 1
>         return self.n != 0
> 
> 
> if __name__ == '__main__':
>     loop = Loop(10)
>     while loop:

Whoops.  Should be "while loop()".

>         print "OK"



More information about the Python-list mailing list