True == 1 weirdness

Chris Angelico rosuav at gmail.com
Thu Sep 17 22:03:26 EDT 2015


On Fri, Sep 18, 2015 at 7:38 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Random832 <random832 at fastmail.com>:
>
>> It being *easier to implement* to have comparison operators be a
>> single class and have chaining apply equally to all of them may be an
>> excuse for the language to allow it, but it's certainly not an excuse
>> for *actually* using it from a standpoint of good style and
>> readability.
>
> In general, I don't like such caveats. Either something is in the
> language or it is not.
>
> You don't have to use all language features (I certainly don't), but if
> somebody takes advantage of them, you shouldn't consider it bad style.
> So if you don't like
>
>     if prev_node is not node in excluded:
>          ...
>
> take your complaints to whoever accepted the syntax in the language.

Strongly disagree. We have style guides because the language allows
many things which are not good code. Given that Python programmers
can't decide on whether the line limit should be 79, 80, 100, 120, or
"79 but you can stretch to 100 if you have to", what should the syntax
be coded to? It's just as bad style to produce a 500-character line as
it is to abuse operator chaining, so should we take our complaints
about over-long lines to "whoever didn't put a length limit into
language syntax"? What about indenting with 5 spaces - should that
have been disallowed at the language level? And what about misspelled
comments - obviously they're bad style, so clearly Python should raise
SyntaxError any time it comes across one, right?

No. The language should be kept simple, and on matters of style, it
should have MORE flexibility than we use - otherwise it's a
straitjacket.

ChrisA



More information about the Python-list mailing list