True inconsistency in Python

Ron Adam radam2 at
Thu Nov 13 07:26:09 CET 2003

On Wed, 12 Nov 2003 19:42:27 -0800, Scott Chapman
<scott_list at> wrote:

>Historically Python has allowed <> 0 to equal true in evaluations.  Now 
><> 0 still evaluates to true in evaluations. However it doesn't equal  

>>>a = (2 != 0)
>>>a == 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