while True or while 1
Arnaud Delobelle
arnodel at gmail.com
Tue Dec 14 11:52:38 EST 2010
Gregory Ewing <greg.ewing at canterbury.ac.nz> writes:
> Steven D'Aprano wrote:
>
>>>>>while True:
>>
>> ... print "Looping"
>> ... True = 0
>
> Just remember that if you use that inside a function, you'll
> have to initialise True to True before... er, wait a moment,
> that won't work... ah, I know:
>
> def f(true = True):
> True = true
> while True:
> ...
> True = False
You also need to initialise False to False for it to be really
robust. So something like this will do.
True = not 0
False = not True
while True:
...
True = False
:)
--
Arnaud
More information about the Python-list
mailing list