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

Vernon D. Cole vernondcole at gmail.com
Fri May 17 10:35:20 CEST 2013


Terry Jan Reedy wrote:

>
> 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
>
> It appears that my intuition is far different.  I distinctly remember that
when I was first learning Python and read that you _cannot_ put a comment
after a line continuation -- my comment was: "What??  Why not?"  Followed
by: "Oh, well, if _that_ is the only thing wrong with the language I will
probably use it a lot."

 +1 for \ #  Can I vote more than once?

On the other hand, implicit string literal concatenation is so obscure
that, when I really needed it a week or two ago, I went back to the
documentation to make sure that it was really part of Python, and not some
other syntax that I was remembering.  (Sometimes I have trouble keeping my
Grandchildren sorted out, too.)  I could not locate it in the docs and so
solved the problem another way.  This discussion has helped restore my
faith in my memory.

+1 for deprecating it -- in Python 4. Mark it as bad code smell as soon as
there is an alternative.

Do we need an _explicit_ string literal concatenation operator?  Yes, we
do, in order to deprecate the implicit, and as we all know: "Explicit is
better than implicit."

+1

What should that operator be?  '+' is obvious.  Too obvious.  I would
always wonder, somewhere deep down inside my soul: did the compiler
_really_ optimize the expression, or is it being evaluated at run time,
every time it passes through the loop?  I would avoid using it in practice
for that reason alone.

I don't like the use of a dot, because, at my age, it is getting pretty
hard to tell them apart from a comma. Besides, '.' is already pretty busy
being an attribute marker and the marker which differentiates a float from
an int.

My favorite candidate so far is the humble, under used, ellipses.  Does it
even _have_ an operator precedence?  I don't know, because in ten years of
Python coding I have never used it. I have used "if someFeature is
NotImplemented:" and I think that reads pretty well.  Ellipses, on the
other hand, I have never found a use for.  I know it exists, but...

And, as you see, a native English speaker indicates that there is something
else missing, to be filled in later, when an ellipses appears at the end of
something.  Not all good ideas come from the Dutch ... sometimes they come
from Antipodes.

+1 for "..."
--
Vernon Cole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130517/ceb7fa0c/attachment.html>


More information about the Python-ideas mailing list