Re: How best to convert a string "list" to a python list

2011-05-14 Thread Terry Reedy
On 5/14/2011 4:41 AM, Nobody wrote: On Fri, 13 May 2011 10:15:29 -0700, noydb wrote: I want some code to take the items in a semi-colon-delimted string "list" and places each in a python list. I came up with below. In the name of learning how to do things properly, do you experts have a bette

Re: How best to convert a string "list" to a python list

2011-05-14 Thread Daniel Kluev
On Sat, May 14, 2011 at 7:41 PM, Nobody wrote: > to use a regular expression to match everything up to the next delimiter, > and do this in a loop to extract the individual items. re.findall() should let you match all items at once, without loop. -- With best regards, Daniel Kluev -- http://ma

Re: How best to convert a string "list" to a python list

2011-05-14 Thread Nobody
On Fri, 13 May 2011 10:15:29 -0700, noydb wrote: > I want some code to take the items in a semi-colon-delimted string "list" > and places each in a python list. I came up with below. In the name of > learning how to do things properly, do you experts have a better way of > doing it? > x = "red;

Re: How best to convert a string "list" to a python list

2011-05-13 Thread John Posner
On 5/13/2011 3:38 PM, noydb wrote: > I want some code to take the items in a semi-colon-delimted string > "list" and places each in a python list. I came up with below. In > the name of learning how to do things properly, No big deal that you weren't aware of the split() method for strings. Sin

Re: How best to convert a string "list" to a python list

2011-05-13 Thread Eric Snow
On Fri, May 13, 2011 at 11:15 AM, noydb wrote: > I want some code to take the items in a semi-colon-delimted string > "list" and places each in a python list. I came up with below. In > the name of learning how to do things properly, do you experts have a > better way of doing it? > > Thanks fo

Re: How best to convert a string "list" to a python list

2011-05-13 Thread Redcat
On Fri, 13 May 2011 10:15:29 -0700, noydb wrote: > I want some code to take the items in a semi-colon-delimted string > "list" and places each in a python list. I came up with below. In the > name of learning how to do things properly, do you experts have a better > way of doing it? How about t

Re: How best to convert a string "list" to a python list

2011-05-13 Thread MRAB
On 13/05/2011 18:15, noydb wrote: I want some code to take the items in a semi-colon-delimted string "list" and places each in a python list. I came up with below. In the name of learning how to do things properly, do you experts have a better way of doing it? Thanks for any inputs! *** x = "

Re: How best to convert a string "list" to a python list

2011-05-13 Thread noydb
On May 13, 1:25 pm, Mark Niemczyk wrote: > 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',

Re: How best to convert a string "list" to a python list

2011-05-13 Thread Jerry Hill
On Fri, May 13, 2011 at 1:15 PM, noydb wrote: > I want some code to take the items in a semi-colon-delimted string > "list" and places each in a python list.  I came up with below.  In > the name of learning how to do things properly, do you experts have a > better way of doing it? Strings have a

Re: How best to convert a string "list" to a python list

2011-05-13 Thread Mark Niemczyk
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 discussio

How best to convert a string "list" to a python list

2011-05-13 Thread noydb
I want some code to take the items in a semi-colon-delimted string "list" and places each in a python list. I came up with below. In the name of learning how to do things properly, do you experts have a better way of doing it? Thanks for any inputs! *** x = "red;blue;green;yellow" ## string of