Newcomer struggling with tutorial

Andrew Bennetts andrew-pythonlist at puzzling.org
Sat Oct 4 23:36:57 EDT 2003


On Sun, Oct 05, 2003 at 03:17:31AM +0000, CPK Smithies wrote:
> Just joined this group, fascinated by Python. Many thanks to those who have 
> worked so hard on it!
> 
> One big problem, though: I was completely thrown by this, which I quote 
> from the Tutorial:
> 
> > Comparisons can be chained. For example, a < b == c tests whether a is 
> less than b and moreover b equals c.
> 
> 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

Did you type this from memory, rather than copying and pasting?  This is
what I see:

>>> a = -1
>>> b = 77
>>> c =  1
>>> (a < b)
True
>>> True == c
True
>>> (a < b) == c
True
>>> a < b == c
False
>>> (a < b) and (b == c)
False


Do you see the distinction?  "a < b == c" is the same as writing "(a < b)
and (b == c)" in python, but "(a < b) == c" isn't.  Perhaps the tutorial's
wording is unclear.

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

Then why are you posting here? ;)

-Andrew.






More information about the Python-list mailing list