sum and strings
Georg Brandl
g.brandl-nospam at gmx.net
Sat Aug 19 01:39:57 EDT 2006
Paul Rubin wrote:
> Georg Brandl <g.brandl-nospam at gmx.net> writes:
>> Why would you try to sum up strings? Besides, the ''.join idiom is quite
>> common in Python.
>
> Just because it's common doesn't mean it's obvious. In my opinion
> it's as ugly as sin, and the fact that it's an idiom shows a
> shortcoming in Python. The obvious reason for summing strings is that
> it's a long-established feature of Python that a+b concatenates two
> strings, so summing a,b,c,d,e should result in a+b+c+d+e.
Which is exactly how I would concatenate five strings.
For concatenating longer sequences of strings, however, if it needs to be
done fast, performance-wise, this approach is not sensible.
Georg
More information about the Python-list
mailing list