I don't get why sys.exit(1) doesn't exit the while loop in the follow case
__peter__ at web.de
Mon Oct 11 14:13:37 CEST 2010
Steven D'Aprano wrote:
> On Tue, 05 Oct 2010 13:57:11 +1100, Ben Finney wrote:
>> chad <cdalten at gmail.com> writes:
>>> while 1:
>> A minor point: this is more explanatory and less misleading if you write
>> it as ‘while True’.
> Why is it misleading? Is there some circumstance in Python where the
> literal 1 could have a false value?
>>> while True:
... print "forever"
So, if I were to play advocatus diaboli I'd argue that 'while True: ...' is
more likely to mislead because 'True' could be anything.
PS: The above is no longer possible in Python 3 where True and False have
More information about the Python-list