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

Nick Maclaren nmm1 at cus.cam.ac.uk
Wed Apr 5 04:56:30 EDT 2000


In article <slrn8el1su.3h1.quinn at riyal.ugcs.caltech.edu>,
Quinn Dunkan <quinn at riyal.ugcs.caltech.edu> wrote:
>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?

Dunno.  If I remember correctly, the three operand form was there in
an early version of SPSS (late 1960s.)


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



More information about the Python-list mailing list