Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5311
| From | Mark Niemczyk <prahamark@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: How best to convert a string "list" to a python list |
| Date | 2011-05-13 10:25 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <fb2d4d85-ad4e-4ecd-9ec0-0fb122af61a4@glegroupsg2000goo.googlegroups.com> (permalink) |
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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: How best to convert a string "list" to a python list Mark Niemczyk <prahamark@gmail.com> - 2011-05-13 10:25 -0700 Re: How best to convert a string "list" to a python list noydb <jenn.duerr@gmail.com> - 2011-05-13 10:31 -0700
csiph-web