How best to convert a string "list" to a python list
Mark Niemczyk
prahamark at gmail.com
Fri May 13 13:25:54 EDT 2011
There are a series of built-in methods for string objects; including the split method which will accomplish exactly the result you are looking for.
>>> x = "red;blue;green;yellow"
>>> color_list = x.split(';')
>>> color_list
['red', 'blue', 'green', 'yellow']
>>>
Here is the link to a discussion of the build-in str methods (3.2), but this documentation exists for prior versions of Python as well.
http://docs.python.org/py3k/library/stdtypes.html#str.split
Good luck,
Mark Niemczyk
More information about the Python-list
mailing list