Newcomer struggling with tutorial

Peter Hansen peter at engcorp.com
Sun Oct 5 05:26:47 CEST 2003


CPK Smithies wrote:
> 
> I threw a mental wobbly and wasted two hours over this:
> 
> a = -1
> b = 77
> c =  1
> 
> (a < b)
>  True
> 
> True == c
>  True
> 
> (a < b) == c
>  False
> 
> Unfortunately I was brought up with the belief that if A == B and B == C,
> then A should == C.

Strangely enough it does.  Your last line is incorrect.  Try executing
it again, from scratch, without reassigning any of the three values
you originally entered, because that's surely what you have done to
get that result.

Using Python 2.3:

C:\>python
Python 2.3.1 (#47, Sep 23 2003, 23:47:32) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = -1
>>> b = 77
>>> c = 1
>>> a < b
True
>>> True
True
>>> True == c
True
>>> (a < b) == c
True

> I confess that after two hours worrying about this I have given up on
> Python and uninstalled it. A shame: it looked so good!

A shame indeed, were it in fact how Python worked.

-Peter




More information about the Python-list mailing list