[Python-ideas] Descouraging the implicit string concatenation

Stephan Houben stephanh42 at gmail.com
Wed Mar 14 10:09:28 EDT 2018


Note that this has already been proposed and rejected before:

https://www.python.org/dev/peps/pep-3126/

Stephan

Op 14 mrt. 2018 15:01 schreef "Oleg Broytman" <phd at phdru.name>:

> On Thu, Mar 15, 2018 at 12:15:52AM +1100, Steven D'Aprano <
> steve at pearwood.info> wrote:
> > On Wed, Mar 14, 2018 at 09:18:30AM -0300, Facundo Batista wrote:
> > > We should write the following, instead:
> > >
> > >     long_string = (
> > >         "some part of the string " +
> > >         "with more words, actually is the same " +
> > >         "string that the compiler puts together")
> >
> > Should we? I disagree.
> >
> > Of course you're welcome to specify that in your own style-guide for
> > your own code, but I won't be following that recommendation.
> >
> >
> > > I know that "no change to Python itself" is needed, but having a
> > > formal discouragement of the idiom will help in avoiding people to
> > > fall in mistakes like:
> > >
> > > fruits = {
> > >     "apple",
> > >     "orange"
> > >     "banana",
> > >     "melon",
> > > }
> >
> > People can make all sorts of mistakes through carlessness. I wrote
> >
> >     {y, x*3}
> >
> > the other day instead of {y: x**3}. (That's *two* errors in one simple
> > expression. I wish I could say it was a record for me.) Should we
> > "discourage" exponentiation and dict displays and insist on writing
> > dict((y, x*x*x)) to avoid the risk of errors? I don't think so.
>
>    We should fix what causes real problems, not convoluted ones. And
> this particular misfeature caused problems for me.
>
> > --
> > Steve
>
> Oleg.
> --
>      Oleg Broytman            http://phdru.name/            phd at phdru.name
>            Programmers don't die, they just GOSUB without RETURN.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180314/9f126b22/attachment.html>


More information about the Python-ideas mailing list