[Python-ideas] Allowing comments after line continuations

Bruce Leban bruce at leapyear.org
Fri May 17 04:44:31 CEST 2013


On May 16, 2013 5:05 PM, "Terry Jan Reedy" <tjreedy at udel.edu> wrote:

> To me, having the \ below escape the newline that occurs 60 characters
later is 'counter-intuitive'.
>
> a + \ # a very long comment that seems to go on and on forever
>
> The \ where it is looks to me like a stray typo and a bug. I would be
less surprised if the code below worked, so my counter-proposal is that \
escaping of newline work after comments.
>
> >>> 1 + # current behavior \
> SyntaxError: invalid syntax
>
> >>> 1 + # proposed behavior \
>     2
> 3
>
> >>>
>
> > and less-than-useful behaviour, which IMO it does.
>
> Useful is a different issue. My counte-proposal meets the goal of mixing
comments with line-continuation.

My objection to this is that it changes meaning of current code while my
proposal doesn't. It also changes rule that everything after # is ignored.
Simple example:

    x = y,   # \
    z = 1, 2

Admittedly contrived but I spent no time trying to get a less-contrived
example.

--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130516/8dd2cdac/attachment.html>


More information about the Python-ideas mailing list