Is this valid ?

Rolf van de Krol python at rolfvandekrol.nl
Thu Mar 20 10:09:08 EDT 2008


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. 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. The fact that python understand the 
obvious meaning of this code, is quite unique to Python, as far as I know.



More information about the Python-list mailing list