Re: "Opposite" of splitting?

2005-06-05 Thread Paul Rubin
Jan Danielsson <[EMAIL PROTECTED]> writes:
> I have a list of integers:
> q = [ 1, 2, 4, 7, 9 ]
> which I would like to convert to a string:
> "1,2,4,7,9"

s = ','.join([str(n) for n in q])

Alternatively, just repr(q) gives you '[1, 2, 4, 7, 9]' (with the
brackets and spaces).
-- 
http://mail.python.org/mailman/listinfo/python-list


"Opposite" of splitting?

2005-06-05 Thread Jan Danielsson
Hello all,

I have a list of integers:

q = [ 1, 2, 4, 7, 9 ]

which I would like to convert to a string:

"1,2,4,7,9"

   This is *very* easy to do with a simple while loop.. But I suspect
that there is a more elegant way to do it in Python. Is there? If so: How?
-- 
http://mail.python.org/mailman/listinfo/python-list