
On 16/05/2013 18:26, Bruce Leban wrote:
On Thu, May 16, 2013 at 9:57 AM, Christian Tismer <tismer@stackless.com <mailto:tismer@stackless.com>> wrote:
The "&" is not a valid operator on strings and looks pretty much like gluing parts together. It is better than the "\" that just escapes the newline and cannot take comments.
I don't like something that is a standard operator becoming special syntax. While it's true that string & string is not valid, it's not the case that string & ... is not valid. I dislike dot for the same reason. It's confusing that these would do different things:
'abc' & 'def' ('abc') & 'def'
I like the \ idea because it's clearly syntax and not an operator, but the fact that it doesn't work with comments is annoying since one reason to break a string is to insert comments. I don't like that spaces after the \ are not allowed because trailing spaces are invisible to me but not to the parser. So what if the rule for trailing \ was changed to:
The \ continuation character may be followed by white space and a comment. If a comment is present, there must be at least one whitespace character between the \ and the comment.
Why do you say """there must be at least one whitespace character between the \ and the comment"""?
That is:
x = [ # THIS WOULD BE ALLOWED 'abc' \ 'def' \ # not the python keyword 'ghi' ]
x = [ # THIS WOULD BE AN ERROR 'abc' \ 'def' # a comment but no continuation \ 'ghi' ]
One thing I like about using \ is that it already works (aside from my proposed comment change). So anyone wanting to write forward/backward-compatible code can just add the \s now. If you want to start enforcing the restriction, just use from __future__ import explicit_string_continuation.