while True or while 1

Grant Edwards invalid at invalid.invalid
Mon Dec 13 10:49:12 EST 2010


On 2010-12-12, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:

> With the "while True" idiom in Python 2.x, you can easily exit out of an 
> infinite loop without using break:
>
>>>> while True:
> ...     print "Looping"
> ...     True = 0
> ...
> Looping
>>>>
>>>> while True:  # Execute an infinite loop in 0 seconds.
> ...     print "Looping"
> ...
>>>>
>
> *wink*

Sadly, I've seen people do stuff like that in real programs...

-- 
Grant Edwards               grant.b.edwards        Yow! I was making donuts
                                  at               and now I'm on a bus!
                              gmail.com            



More information about the Python-list mailing list