True inconsistency in Python
aleax at aleax.it
Thu Nov 13 15:18:13 CET 2003
Ben Finney wrote:
> This conflation of types is confusing, and (like many other languages)
> Python has now "grown a Boolean type" to distinguish integer 0 and 1
> from Boolean False and True. However, the previous behaviour is still
> supported -- for how long, I don't know.
I've never heard of any plans (not even for the totally mythical
"Python 3000") to remove or even deprecate Python's extremely useful
and practical feature that:
-- any value can be used as a true-or-false condition,
-- zero numbers, empty containers, and user-coded objects defining
__nonzero__ (or else __len__) and returning 0 are taken as false,
-- all other values are taken as true.
More information about the Python-list