Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Redcat Newsgroups: comp.lang.python Subject: Re: How best to convert a string "list" to a python list Date: 13 May 2011 19:26:40 GMT Lines: 19 Message-ID: <935evgF8cmU1@mid.individual.net> References: <2efc3a05-22e5-46db-bd22-c95221bbd7b2@k16g2000yqm.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net wRIZjVUtcZ5rm5osp5zyBAh+EQKJjUCUiXaS1Pq5AM4vxjxEJK Cancel-Lock: sha1:oJkGBmDaHgFa3RPceXmrEauHrRA= User-Agent: Pan/0.133 (House of Butterflies) Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5318 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 the below? dan@dan:~/development$ python Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = "cyan;magenta;yellow;black" >>> xList = x.split(';') >>> xList ['cyan', 'magenta', 'yellow', 'black'] >>>