How to convert a list of strings into a list of variables
roy at panix.com
Fri Aug 19 14:57:54 CEST 2011
<2ab25f69-6017-42a6-a7ef-c71bc2ee8547 at l2g2000vbn.googlegroups.com>,
noydb <jenn.duerr at gmail.com> wrote:
> How would you convert a list of strings into a list of variables using
> the same name of the strings?
> So, ["red", "one", "maple"] into [red, one, maple]
> Thanks for any help!
I'm not sure what you're trying to do, but explore the dictionary
returned by locals(). You can do something like:
loc = locals()
[loc["red"], loc["one"], loc["maple"]]
More information about the Python-list