define loop statement?

Georg Brandl g.brandl-nospam at gmx.net
Sat Feb 18 15:32:16 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:
> 		print "OK"

Seems you forgot "()" after "while loop" above.

Georg



More information about the Python-list mailing list