On Mar 21, 1:09 am, Rolf van de Krol <[EMAIL PROTECTED]> 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.
'Of course' was short for: Given alternative hypotheses H0 = "Python feature" and H1 = "bug in Python compiler", one's instinct would be go with H0 if a snap decision were required without time to refer to the docs. > Although the Stef > Mientki would probably be able to find it in the documentation it is not > as simple as you might think. > Most languages interpret a == b == 2 as (a == b) == 2, or throw an error > because this syntax is not valid. Indeed, some languages do ludicrous things with precedence of relational operators. A compiler when faced with something like: a == b and c == d has at least two choices: (1) (a == b) and (c == d) # seems rather useful (2) (a == (b and c)) == d which doesn't seem very useful at all. Pascal makes choice (2), which is valid syntax only if b and c are booleans and if comparisons of booleans are allowed (and IIRC Pascal didn't allow this). > The fact that python understand the > obvious meaning of this code, is quite unique to Python, as far as I know. Indeed, Python isn't "some/most languages", which is why we're here. -- http://mail.python.org/mailman/listinfo/python-list