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

Ian Cordasco graffatcolmingov at gmail.com
Sat May 11 20:57:49 CEST 2013


On Sat, May 11, 2013 at 2:52 PM, Mark Janssen <dreamingforward at gmail.com> wrote:
>>>> Maybe we could turn ... into a "string continuation
>>>> operator":
>>>>
>>>>   print("This is example %d of a line that is "...
>>>>         "too long" % example_number)
>>>
>>> I think that is an awesome idea.
>>
>> How is this any better than + in the same position? It's harder to notice, and longer (remember that the only reason you're doing this is that you can't fit your strings into 80 cols).
>
> It partitions the conceptual space.  "+" is a mathematical operator,
> but strings are not numbers.  That's the negative argument for it.
> The positive, further, argument is that the elipsis has a long history
> of being a continuation indicator in text.

But + is already a supported operation on strings and has been since
at least python 2. It is already there and it doesn't require a new
dunder method for concatenating with the Ellipsis object. It's also
relatively fast and already performed at compile time. If we're going
to remove this implicit concatenation, why do we have to add a fancy
new feature that's non-obvious and going to need extra implementation?

>> By the way, is it just a coincidence that almost all of the people sticking up for keeping or replacing implicit concatenation instead of just scrapping it are using % formatting in their examples?
>
> An interesting correlation indeed.

Albeit one that is probably unrelated. I use str.format everywhere
(mostly because I don't support python 2.5 in most of my work) and I'm
against it. I just haven't given examples against it because others
have already presented examples that I would have provided.



More information about the Python-ideas mailing list