[Python-ideas] Allowing comments after line continuations

Terry Jan Reedy tjreedy at udel.edu
Fri May 17 22:06:30 CEST 2013


On 5/17/2013 4:59 AM, Steven D'Aprano wrote:
> On 17/05/13 10:04, Terry Jan Reedy 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

> You're misreading it, in my (not-so-)humble opinion :-)
Yes, it is a rather imperious opinion ;-)

> The backslash should not be interpreted as an escape, since escapes are
> only meaningful inside string literals.

'Escape' means 'ignore the normal meaning of the following character'.
That is exactly what \<newline> means. 'Excape' had that meaning long 
before there were python string literals. Ditto for the use of \ as an 
escape character, as in relational expressions. Relational expressions 
are typically not quoted, and the fact that they are in Python code, to 
first turn them into string objects rather than pattern objects, is a 
nuisance that lead to the r prefix hack.

Do you really think Guido just coincidentally choose \ to escape 
newline, ignorant of its two decade history in unix?

Anyway, this is all moot unless the syntax is changed in a way that 
forces a different interpretation. I don't think that is needed.

Terry




More information about the Python-ideas mailing list