Abandoned wrote:
> I want to convert a string to command..
> For example i have a string:
> a="['1']"
> I want to do this list..
> How can i do ?
The correct wording here would be expression. To evaluate expressions, there
is the function eval:
a = eval("['1']")
But beware: if the expression contains some potentially harmful code, it
will be executed. So it is generally considered bad style to use eval.
An example that fails would be
a = eval("10**2000**2000")
or such thing.
Another alternative is to use parsers like simplejson to extract the
information. This of course only works, if your expressions are valid json.
Diez
--
http://mail.python.org/mailman/listinfo/python-list