how do i change from string to list
Alex Martelli
aleaxit at yahoo.com
Mon Oct 25 06:20:27 EDT 2004
Andrew Dalke <adalke at mindspring.com> 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'.
Alex
More information about the Python-list
mailing list