while 1 vs while True

Steven Bethard steven.bethard at gmail.com
Tue Dec 14 18:12:34 CET 2004

Steve Holden wrote:
> # Pre 2.2.1 compat.
> try: True, False
> except NameError: True = 1==1; False = 1==0
> I believe this should work for all versions up to 2.4, and would also 
> work with a 2.5 that made True and False constants. But if anyone can 
> prove me wrong it would be you ... :-)

Seems like it might work, though we couldn't have the SyntaxError like 
we do for None:

 >>> try:
...     None
... except NameError:
...     None = 0
Traceback (SyntaxError: assignment to None

Note that even though I don't actually enter the except block, I still 
get a SyntaxError.

Another Steve

More information about the Python-list mailing list