Why doesn't join() call str() on its arguments?
Leo Breebaart
leo at lspace.org
Wed Feb 16 18:29:30 EST 2005
"Delaney, Timothy C (Timothy)" <tdelaney at avaya.com> writes:
> John Roth wrote:
>
> > result = "".join([str(x) for x in list])
>
> As of 2.4, you should use a generator expression here instead (unless
> you require backwards-compatibility with 2.3).
>
> result = ''.join(str(x) for x in iterable)
>
> Easier to read, more memory-efficient, potentially faster (depending on
> performance characteristics of building large lists).
Stop me if I sound too whiney, but in my original post that
started this thread just a couple of hours ago, I did in fact get
this right, so I'm not entirely sure who the two of you are
actually talking to...
--
Leo Breebaart <leo at lspace.org>
More information about the Python-list
mailing list