code review

Chris Angelico rosuav at gmail.com
Mon Jul 2 10:20:57 CEST 2012


On Mon, Jul 2, 2012 at 6:11 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> "c" < first_word < second_word == third_word < "x"
>
> I'm sure I don't have to explain what that means -- that standard chained
> notation for comparisons is obvious and simple.
>
> In Python, you write it the normal way, as above. But some other
> languages force you into verbosity:
>
> ("c" < first_word) and (first_word < second_word) and (second_word ==
> third_word) and (third_word < "x")

Uhh, actually you DO have to explain that, because I interpreted it
quite differently:

(("c" < first_word) and (first_word < second_word)) == (third_word < "x")

And even if you can prove that my interpretation is wrong, it's still
plausible enough that I, as a programmer, would have to dive to the
manual (or test in interactive interpreter) to find out which way the
language evaluates this.

ChrisA



More information about the Python-list mailing list