[Python-ideas] Allowing comments after line continuations
Terry Jan Reedy
tjreedy at udel.edu
Fri May 17 02:04:26 CEST 2013
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.
Terry
More information about the Python-ideas
mailing list