blessed be Guido, for "5 <= X <= 10" does what it should...

Quinn Dunkan quinn at riyal.ugcs.caltech.edu
Tue Apr 4 20:21:45 EDT 2000


On Tue, 4 Apr 2000 13:42:41 -0500, Warren Postma <embed at geocities.com> wrote:
><X-DISCLAIMER: I'm in a weird mood.>
>
>I was just playing around today,and it occurred to me to test the
>'transitive' properties of comparison operators. Ie, writing on a
>chalkboard, you might say X is in the range 5..9 this way:
>
>        5 <= X <= 9

Yes, this has always struck me as one of the weirder corners of python.
There's a bit of magic for comparison operators:

>From the lang ref 5.9:

Formally, if a, b, c, ..., y, z are expressions and opa, opb, ..., opy are
comparison operators, then a opa b opb c ...y opy z is equivalent to a opa b
and b opb c and ... y opy z, except that each expression is evaluated at most
once. 


It's kinda cool, I guess.  Maybe ABC did it first?



More information about the Python-list mailing list