Newcomer struggling with tutorial

David Lees abcdebl2nonspammy at verizon.net
Sun Oct 5 00:14:30 EDT 2003


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
> 
> Unfortunately I was brought up with the belief that if A == B and B == C, 
> then A should == C.
> 
> I confess that after two hours worrying about this I have given up on 
> Python and uninstalled it. A shame: it looked so good!
> 
> CPKS
I have not read the tutorial, but the section you quote is quite clear 
about what chaining means.  I did not know about this, but it is kind of 
neat.  For example:

 >>> a = 1; b = 2; c = 3; d = 4
 >>> a < b < c < d < 5
True
 >>> a < b < c < d < 3
False

Python actually conforms more to standard math notation for transitivity 
than whatever language you were 'brought up' on, which results in 
confusion when you are used to standard algebraic notation.  I still 
recall 39 years ago being quite puzzled when I saw the statement:
LET A = A+1

Good luck with whatever language you choose.  Personally, I have found 
Python to be a wonderful practical tool for the occasional programmer 
like me.  And this group is a nice community for the isolated user 
because someone usually supplies answers quickly and non-judgementally 
(for the most part).

david







More information about the Python-list mailing list