Why doesn't join() call str() on its arguments?

Nick Vargish nav+posts at bandersnatch.org
Wed Feb 16 16:52:22 EST 2005


Leo Breebaart <leo at lspace.org> writes:

> That suggests
> to me an "obvious default" of the kind that exists elsewhere in
> Python as well.

I feel pretty much the opposite... If a non-string-type has managed to
get into my list-of-strings, then something has gone wrong and I would
like to know about this potential problem.

If you want to do force a conversion before the join, you can use a 
list comp:

', '.join([str(x) for x in l])


Nick "Explicit is better than Implicit"

-- 
#  sigmask  ||  0.2  ||  20030107  ||  public domain  ||  feed this to a python
print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?')



More information about the Python-list mailing list