[Python-ideas] Allowing comments after line continuations

Ron Adam ron3200 at gmail.com
Fri May 17 05:00:01 CEST 2013



On 05/16/2013 07:04 PM, 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*.

It only escapes pairs it knows about.  If the \ is followed by a character 
that isn't an escape sequence it knows, then it is just a slash.

 >>> "This \ is just a backslash."
'This \\ is just a backslash.'

It would be easier if this wasn't the current behaviour.



>> 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.

This is a matter of style.  It's why I put more space in front of the # if 
there is room.

Ron













More information about the Python-ideas mailing list