Implicit conversion to boolean in if and while statements
bahamutzero8825 at gmail.com
Sun Jul 15 10:34:46 CEST 2012
This has probably been discussed before, but why is there an implicit
conversion to a boolean in if and while statements?
if not None:
prints 'hi' since bool(None) is False.
If this was discussed in a PEP, I would like a link to it. There are so
many PEPs, and I wouldn't know which ones to look through.
Converting 0 and 1 to False and True seems reasonable, but I don't see
the point in converting other arbitrary values.
CPython 3.3.0b1 | Windows NT 6.1.7601.17803
More information about the Python-list