sum(strings)

Mel Wilson mwilson at the-wire.com
Fri Jun 20 09:08:26 EDT 2003


In article <bcttfu$n5trq$1 at ID-169208.news.dfncis.de>,
"Greg Ewing (using news.cis.dfn.de)" <g2h5dqi002 at sneakemail.com> wrote:
>Raymond Hettinger wrote:
>> Because there is just one right way to do it:
>>
>>     "".join([str1, str2, str3, ...])
>
>Hmmm... maybe this ought to be the "right"
>way to do summing as well:
>
>   total = 0.join([17, 42, 88])

   Interesting point arose the other day.. using '+' to
concatenate strings is wrong, because concatenation isn't
commutative.

   Not that it would necessarily affect my thinking if I
were designing a computer language, but it is a sensible
point.  It might trip up a naive optimizer.

        Regards.        Mel.




More information about the Python-list mailing list