[Python-Dev] Usage of += on strings in loops in stdlib (original) (raw)

Daniel Holth dholth at gmail.com
Wed Feb 13 14:17:03 CET 2013


On Wed, Feb 13, 2013 at 7:10 AM, Serhiy Storchaka <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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130213/3a1a9ac0/attachment.html>



More information about the Python-Dev mailing list