Newcomer struggling with tutorial
Terry Reedy
tjreedy at udel.edu
Sun Oct 5 00:39:50 EDT 2003
More information about the Python-list mailing list
Sun Oct 5 00:39:50 EDT 2003
- Previous message (by thread): Newcomer struggling with tutorial
- Next message (by thread): Newcomer struggling with tutorial
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"CPK Smithies" <cpks at NOSPAM.btopenworld.com> wrote in message news:blo2gb$ng0$1 at hercules.btinternet.com... > from the Tutorial: > > > Comparisons can be chained. For example, a < b == c tests whether a is > > less than b and moreover b equals c. This means that a < b == c is equivalent to (a < b) and (b == c) and not (a < b) == c., which is something else. Chained operators are *not* 'associative' -- you cannot insert parens unless you so for each overlapping pair of args and insert 'and' between each. > I threw a mental wobbly and wasted two hours over this: > > a = -1 > b = 77 > c = 1 > > (a < b) > True > > True == c > True For a < b == c, the second test Python makes is b==c (False). But this matches for your next test. > (a < b) == c > False For 2.2.1 (which does not have True/False on Windows . >>> a,b,c = -1, 77, 1 >>> a < b 1 >>> (a < b) == 1 1 What version/machine were you running? Please cut and paste actual output. If you have really discovered a bug in current Python, we would want to know and fix it. > Unfortunately I was brought up with the belief that if A == B and B == C, > then A should == C. Why 'unfortunately'? For builtin objects, this is true in Python. > I confess that after two hours worrying about this I have given up on > Python and uninstalled it. A shame: it looked so good! If you really did that, it was a real shame. Terry J. Reedy
- Previous message (by thread): Newcomer struggling with tutorial
- Next message (by thread): Newcomer struggling with tutorial
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list