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

Christian Tismer tismer at stackless.com
Wed Feb 13 14:30:21 CET 2013


On 13.02.13 14:17, Daniel Holth wrote:
> On Wed, Feb 13, 2013 at 7:10 AM, Serhiy Storchaka <storchaka at gmail.com 
> <mailto:storchaka at gmail.com>> wrote:
>
>     On 13.02.13 10:52, Larry Hastings wrote:
>
>         I've always hated the "".join(array) idiom for "fast" string
>         concatenation--it's ugly and it flies in the face of TOOWTDI.
>          I think
>         everyone should use "x = a + b + c + d" for string
>         concatenation, and we
>         should just make that fast.
>
>
>     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.
>
>
> Fixed: x = ('%s' *  len(abcd)) % abcd
>

Which becomes in the new formatting style

     x = ('{}' *  len(abcd)).format(*abcd)

hmm, hmm, not soo nice

-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Software Consulting          :     Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121     :    *Starship* http://starship.python.net/
14482 Potsdam                :     PGP key -> http://pgp.uni-mainz.de
phone +49 173 24 18 776  fax +49 (30) 700143-0023
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
       whom do you want to sponsor today?   http://www.stackless.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130213/408e88d8/attachment-0001.html>


More information about the Python-Dev mailing list