[Python-Dev] Usage of += on strings in loops in stdlib

Brett Cannon brett at python.org
Wed Feb 13 19:24:38 CET 2013


On Wed, Feb 13, 2013 at 1:06 PM, Maciej Fijalkowski <fijall at gmail.com>wrote:

> On Wed, Feb 13, 2013 at 7:33 PM, MRAB <python at mrabarnett.plus.com> wrote:
> > On 2013-02-13 13:23, Lennart Regebro wrote:
> >>
> >> On Wed, Feb 13, 2013 at 1:10 PM, Serhiy Storchaka <storchaka at gmail.com>
> >> wrote:
> >>>
> >>> I prefer "x = '%s%s%s%s' % (a, b, c, d)" when string's number is more
> >>> than 3
> >>> and some of them are literal strings.
> >>
> >>
> >> This has the benefit of being slow both on CPython and PyPy. Although
> >> using .format() is even slower. :-)
> >>
> > How about adding a class method for catenation:
> >
> >     str.cat(a, b, c, d)
> >     str.cat([a, b, c, d]) # Equivalent to "".join([a, b, c, d])
> >
> > Each argument could be a string or a list of strings.
> >
> >
> > _______________________________________________
> > Python-Dev mailing list
> > Python-Dev at python.org
> > http://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe:
> > http://mail.python.org/mailman/options/python-dev/fijall%40gmail.com
>
> I actually wonder.
>
> There seems to be the consensus to avoid += (to some extent). Can
> someone commit the change to urrllib then? I'm talking about reverting
> http://bugs.python.org/issue1285086 specifically


Please re-open the bug with a comment as to why and I'm sure someone will
get to it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130213/7eebe93b/attachment.html>


More information about the Python-Dev mailing list