[Python-ideas] Allowing comments after line continuations
Ethan Furman
ethan at stoneleaf.us
Fri May 17 04:05:33 CEST 2013
On 05/16/2013 05: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*.
>>
>> 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
I would rather see Greg's proposal; a backslash is already semi-magical with it's escaping property, so I think it
makes more sense to have a backslash be able to interrupt an expression than a comment... although, having said that,
brackets allow comments in the middle...
I still like Greg's color better. ;)
--
~Ethan~
More information about the Python-ideas
mailing list