Why doesn't join() call str() on its arguments?
Delaney, Timothy C (Timothy)
tdelaney at avaya.com
Wed Feb 16 18:03:01 EST 2005
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).
Tim Delaney
More information about the Python-list
mailing list