True inconsistency in Python
Christopher A. Craig
list-python at ccraig.org
Thu Nov 13 17:48:38 CET 2003
Scott Chapman <scott_list at mischko.com> writes:
> It seems that maybe Python should throw a warning (perhaps if a flag is
> set) any time it bumps into code comparing a variable to True or False.
> It's pretty subtle and would easily throw a newbie.
While I agree with the above assertions that it's totally silly to
compare something with True, throwing a warning isn't desirable. If
you're going to write something to handle this, the tp_compare method
on the bool object should return
PyObject_IsTrue(a) == self->ob_ival ? Py_True : Py_False
Of course about a week after that's done somebody is going to point
out that "3 is True" is false (as it should be).
Christopher A. Craig <list-python at ccraig.org>
But seek first His kingdom and His righteousness and all these things will be
added to you. -- Matt 6:33 (NASB)
More information about the Python-list