[Python-ideas] Implicit string literal concatenation considered harmful?
MRAB
python at mrabarnett.plus.com
Fri May 10 21:54:58 CEST 2013
On 10/05/2013 20:26, Alexander Belopolsky wrote:
>
>
>
> On Fri, May 10, 2013 at 2:48 PM, Guido van Rossum <guido at python.org
> <mailto:guido at python.org>> wrote:
>
> I just spent a few minutes staring at a bug caused by a missing comma
> -- I got a mysterious argument count error because instead of foo('a',
> 'b') I had written foo('a' 'b').
>
>
> I had a similar experience just few weeks ago. The bug was in a long
> list written like this:
>
> ['item11', 'item12', ..., 'item17',
> 'item21', 'item22', ..., 'item27'
> ...
> 'item91', 'item92', ..., 'item97']
>
> Clearly the bug crept in when more items were added. (I try to keep
> redundant commas at the end of the list to avoid this, but not everyone
> likes this style.)
>
>
> Would it be reasonable to start deprecating this and eventually remove
> it from the language?
>
>
> +1, but I would start by requiring () around concatenated strings.
>
I'm not so sure.
Currently, parentheses, brackets and braces effectively make Python
ignore a newline within them.
(1
+2)
is the same as:
(1+2)
and:
[1
+2]
is the same as:
[1+2]
Under the proposal:
("a"
"b")
or:
("a" "b")
would be the same as:
("ab")
but:
["a"
"b"]
or:
["a" "b"]
would be a syntax error.
More information about the Python-ideas
mailing list