On 17/05/2013 01:04, Terry Jan Reedy wrote:
On 5/16/2013 6:26 PM, Greg Ewing wrote:
Terry Jan Reedy wrote:
In a string, \ escapes the immediate next character. This idea of \ at the *end* of a line, just before the newline character, is that it escapes the newline, *just as is does within a string*.
That's how it currently works, but that doesn't mean it's how it *should* work.
My point is that there is a logical consistency that makes the current behavior consistent to me.
Especially if it leads to counter-intuitive
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.
So you want \ to have a special meaning at the end of a comment? I don't even like the current behaviour of \ at the end of a raw string literal! :-) If it _did_ have a special meaning, I would've expected it to indicate that the _comment itself_ is continued onto the next line. -1