String To List

castironpi at gmail.com castironpi at gmail.com
Mon Mar 17 21:09:22 EDT 2008


On Mar 17, 10:26 am, Jeff Schwab <j... at schwabcenter.com> wrote:
> Girish wrote:
> > I have a string a = "['xyz', 'abc']".. I would like to convert it to a
> > list with elements 'xyz' and 'abc'. Is there any simple solution for
> > this??
>
> Do you want:
>
> (1) Specifically to vivify lists formatted as in your example?  If so, why?
>
> (2) To save and restore arbitrary python objects?
>
> (3) To define some kind of configuration file format that you can read
> from Python?

Bar says: Announce your intentions, then contents.  (Form, then
contents.)  == List of two strings.

How does that go into code?

>>> list([str,str])
[<type 'str'>, <type 'str'>]



More information about the Python-list mailing list