code review

Rick Johnson rantingrickjohnson at gmail.com
Mon Jul 2 11:57:14 EDT 2012


On Jul 2, 3:20 am, Chris Angelico <ros... at gmail.com> wrote:
> On Mon, Jul 2, 2012 at 6:11 PM, Steven D'Aprano
>
> <steve+comp.lang.pyt... 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")

Poor Chris. That's because you've been brainwashed into believing you
must spoon feed your interpreter to get your code working correctly.
Stop applying these naive assumptions to Python code. Python knows
when you reach the end of a statement, no need for redundant
semicolons! Python knows when its reached the end of block and needs
to drop back one level, no need for redundant road signs.  Python
knows Chris; Python KNOWS!




More information about the Python-list mailing list