string to list when the contents is a list

Ben Finney ben+python at benfinney.id.au
Wed Feb 17 19:58:19 EST 2010


Wes James <comptekki at gmail.com> writes:

> I have been trying to create a list form a string.  The string will be
> a list (this is the contents will look like a list).  i.e. "[]" or
> "['a','b']"

Pulling back to ask about the larger problem: Are you trying to create
Python data structures from a serialised representation?

There are several well-implemented solutions, including the standard
library modules ‘pickle’ and ‘json’. Do you have control over the choice
of serialisation format?

-- 
 \        “I went to court for a parking ticket; I pleaded insanity. I |
  `\   said ‘Your Honour, who in their right mind parks in the passing |
_o__)                                           lane?’” —Steven Wright |
Ben Finney



More information about the Python-list mailing list