On Mar 20, 6:06 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 20 Mar 2008 15:09:08 +0100, Rolf van de Krol wrote: > > > John Machin wrote: > >> Of course. You can chain comparisons as much as you like and is > >> (semi-)sensible, e.g. > > > Hmm, 'of course' is not the correct word for it. > > Not at all. The Original Poster tried something, and it worked. There > were two alternatives: > > (1) Writing a == b == 2 is valid. > > (2) In the sixteen years that Python has been publicly available, with > tens of thousands or more developers using it, nobody had noticed that > Python had a bug in the compiler which incorrectly allowed a == b == 2 > until Stef Mientki came along and discovered it. > > Given those two alternatives, (2) would be very surprising indeed, and so > I think "of course" is well justified. > > That Python allows chaining comparisons this way isn't really surprising. > That's a very natural thing to do. What's surprising is that other > languages *don't* allow chaining comparisons, but force you to write the > inefficient and (sometimes) confusing "(a == 2) and (b == 2)" instead.
You see a couple of occurrences in natural language-- I'm wondering where the majority of NL settles. >>> a is a is a True Do we do math on booleans on some level or in some contexts? Maybe a "with syntaxchangeA:" is in the future. -- http://mail.python.org/mailman/listinfo/python-list