I'd like it if comments and/or white space could follow the \. Trailing white space after one is always difficult to notice, and the comment after the line continuation is a compelling use-case. Together, we'll have a bit less error prone line continuation syntax.

Sent from Mailbox for iPhone


On Thu, May 16, 2013 at 7:45 PM, Bruce Leban <bruce@leapyear.org> wrote:

On May 16, 2013 5:05 PM, "Terry Jan Reedy" <tjreedy@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