bug in string.join()?

luc lam adom at i.am
Thu Feb 22 10:39:20 EST 2001


Coffee went everywhere when I read that
 Daniel Klein <danielk at aracnet.com> had written:

>On Wed, 21 Feb 2001 20:32:11 +0100, Fernando Rodríguez <spamers at must.die>
>wrote:
>
>>>>> string.join(("abcde"))
>>'a b c d e'
>>
>>Is this the expected behavior, or is it a bug? O:-)
>
>What would you expect it to do? It's already 'joined' without spaces to start
>with.
>
>Dan

It threw me somewhat at first:

>>> import string
>>> list = ["i've","come","for","an","argument"]
>>> print string.join(list)
i've come for an argument
>>> print string.join(list," ")
i've come for an argument
>>> print string.join(list,"")
i'vecomeforanargument
>>>                                      

so the " " is implicit. i've sometimes thought it would be more intuitive to 
have the "" behaviour as the implicit behaviour, but it's simple enough either 
way i guess.

luc



More information about the Python-list mailing list