how do i change from string to list

Alex Martelli aleaxit at
Mon Oct 25 12:20:27 CEST 2004

Andrew Dalke <adalke at> wrote:
>  >>> import cStringIO
>  >>> f = cStringIO.StringIO()
>  >>> for c in list("this is a test"):
> ...   f.write(c)

f.writelines(list('this is a test'))

would appear to me a more natural approach than the loop.  Yeah, the
method's name sucks -- it doesn't just write *lines*, etc.  I guess it
originally came from some sort of parallel with 'readlines'.


More information about the Python-list mailing list