list to string

Ben Hutchings ben.hutchings at roundpoint.com
Tue Feb 27 17:31:50 EST 2001


jgraves3 at austin.rr.com (jay graves) writes:

> On Tue, 27 Feb 2001 02:42:12 GMT, glen mettler <glen.mettler at home.com>
> wrote:
> 
> >These commands will turn a string into a list:
> >myword="dog"
> >mywordlist=list(myword)
> >result = ["d","o","g"]
> >
> >is there a command/function that can take the list ["d","o","g"] and
> >make it a string "dog"?
> 
> One way is to join them.
> 
> ''.join(result)
> 
> Some people don't like using the string methods in this way
<snip>

I'm happy with string methods in general, but I find the semantics of
the above (sending a message to a string to tell it to join a sequence
of strings together with copies of itself) ridiculous.

-- 
Any opinions expressed are my own and not necessarily those of Roundpoint.



More information about the Python-list mailing list