bool constructor is inconsistent?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Sep 10 20:25:07 EDT 2010
On Fri, 10 Sep 2010 14:23:34 -0400, Neal Becker wrote:
> IN [3]: bool('False')
> Out[3]: True
>
> In [4]: int('32')
> Out[4]: 32
Where is the inconsistency? bool('False') returns the same result as for
any other non-empty string:
>>> bool("not true")
True
>>> bool("no")
True
>>> bool("incorrect")
True
>>> bool("wrong")
True
>>> bool("Faux")
True
>>> bool("Falsch")
True
>>> bool("Falso")
True
>>> bool("偽")
True
>>> bool("Ложно")
True
Treating the string "False" as identical to the named global False would
be inconsistent.
--
Steven
More information about the Python-list
mailing list