making a string copy of a list

Tim Peters tim.one at home.com
Sat Jan 13 02:22:11 EST 2001


[Jim Richardson]
> OK, I swear I've looked for this, but how do I make a copy of a 
> list, into a string, complete with commas seperating the entries
> in the list?

Have you tried str()?

>>> x = [1, 2.5, "abc", (1, 2, 3), ['a', 'b']]
>>> s = str(x)
>>> len(s)
38
>>> print s
[1, 2.5, 'abc', (1, 2, 3), ['a', 'b']]
>>>





More information about the Python-list mailing list