True inconsistency in Python
Ron Adam
radam2 at tampabay.rr.com
Thu Nov 13 01:26:09 EST 2003
On Wed, 12 Nov 2003 19:42:27 -0800, Scott Chapman
<scott_list at mischko.com> wrote:
>
>Historically Python has allowed <> 0 to equal true in evaluations. Now
><> 0 still evaluates to true in evaluations. However it doesn't equal
>True.
>>>a = (2 != 0)
>>>a == True
True
Seems to work for me. Am I missing something?
The only thing that surprises me in all of this is the "if var:"
evaluating to true for numbers other than 1. That's new to me, I
would have expected an exception in that case. But it still makes
since if I look at it as a shortcut for "if (var != 0):". This
only proves I'm still relatively new to Python I think.
_Ron Adam
More information about the Python-list
mailing list