while True or while 1

Martin v. Loewis martin at v.loewis.de
Sun Dec 12 16:01:06 EST 2010


>> Python is designed to provide readable code. Writing
>>
>>     while True:
>>         ...
>>
>> is much more legible than its pre-True couterpart
>>
>>     while 1:
>>         ...
> 
> No argue with that!

I actually want to argue with that: I find "while 1" more legible.
That's probably because
a) I'm use to it, and
b) the English words "while" and "True" don't mean much to me,
   I need recognize them, and recognizing "True" is slightly more
   difficult than recognizing "1".

In the end, in any project, there should be coding conventions,
and authors should follow them. What is legible is IMO much more
determined by convention than "intuition", at least to experienced
programmers (i.e. those that have been following the convention for
a long time).

Regards,
Martin



More information about the Python-list mailing list