[Python-ideas] allow line break at operators

Guido van Rossum guido at python.org
Fri Sep 2 15:30:34 EDT 2011


On Fri, Sep 2, 2011 at 12:28 AM, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> Gabriel AHTUNE writes:
>  > So can be done with this syntax:
>  >
>  > > x = firstpart * secondpart  +  #line breaks here
>  > > anotherpart + #continue
>  > > stillanother #continue on.
>  >
>  > after a "+" operator the line is clearly not finished yet.
>
> Sure, but IIRC one design principle of Python is that the keyword that
> denotes the syntax should be the first thing on the line, making it
> easy to scan down the left side of the code to see the syntactic
> structure.  The required indentation of the controlled suite also
> helps emphasize that keyword.

That's true for *statements* (except assignments and calls).

> Analogously, if operators are going to denote continuation, they
> should come first on the line.

That doesn't follow. My preferred style is actually to put the binary
operator at the end of the line. This also matches the prevailing
style for breaking lines after commas (a comma can be seen as a kind
of binary operator).

> I just don't think this idea is going anywhere.  Explicit continuation
> with backslash or implicit continuation of parenthesized expressions
> is just not that heavy a price to pay.  Perhaps historically some of
> these ideas could have been implemented, but now they're just going to
> confuse a host of editors and code analysis tools.

Totally agreed that this isn't going to happen.

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-list mailing list