[Python-ideas] Implicit string literal concatenation considered harmful?

Ron Adam ron3200 at gmail.com
Thu May 16 20:28:11 CEST 2013



On 05/16/2013 02:08 AM, Serhiy Storchaka wrote:

> In all cases only multiline implicit string literal concatenation cause
> problem. What if forbid implicit string literal concatenation only between
> string literals on different physical lines? A deliberate string literal
> concatenation can be made with explicit line joining.

And it already works. It might be a good PEP8 recommendation.

>          ignore_patterns = (
>              'Function "%s" not defined.' % breakpoint,
>              "warning: no loadable sections found in added symbol-file"\
>              " system-supplied DSO",
>              "warning: Unable to find libthread_db matching"\
>              " inferior's thread library, thread debugging will"\
>              " not be available.",
>              "warning: Cannot initialize thread debugging"\
>              " library: Debugger service failed",
>              'warning: Could not load shared library symbols for '\
>              'linux-vdso.so',
>              'warning: Could not load shared library symbols for '\
>              'linux-gate.so',
>              'Do you need "set solib-search-path" or '\
>              '"set sysroot"?',
>              )

In this example, the lines tend to run together visually, and the '\' 
competes with the comma.  But these have more to do with style than syntax 
and can be improved by indenting the continued lines.

I think the line continuation '\' character would also make a good explicit 
string literal concatenation character.  It's already limited to only work 
across sequential lines as well.

Cheers,
    Ron



More information about the Python-ideas mailing list