[Python-ideas] allow line break at operators
bruce at leapyear.org
Thu Aug 11 22:45:58 CEST 2011
On Thu, Aug 11, 2011 at 12:24 PM, Devin Jeanpierre
<jeanpierreda at gmail.com>wrote:
> return 1
> + 5
> Whereas this does not
> 1 + 5
> Of course, Python would have no such problem, because you could make both
> cases unambiguous due to the indent.
> Note that this is already valid and is not a continuation line:
Right now you do not need to indent continuation lines. So in order to
disambiguate you would need to enforce indentation for continuations, but
for backward compatibility that would only be required when not using
parentheses or backslashes. Ick. Can blank lines or comment lines appear
between a line and its continuation? That's allowed now as well.
Now allowing line breaks *after* operators would be unambiguous and would
not require new indentation rules. When a line ends with an operator, it's
clearly incomplete (so no fear the reader will think the statement has ended
unlike the above case) and it's a syntax error today:
return 1 +
x = y > 0 and
y < 10
This code is not valid today without parens or \ regardless of indentation.
I'm +0 on this. I'd use it but does it really add enough convenience?
Follow me: http://www.twitter.com/Vroo http://www.vroospeak.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list