How to convert a list of strings into a list of variables

Kingsley Adio adiksonline at gmail.com
Fri Aug 19 09:39:54 CEST 2011



noydb 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!

red="a string"
one="another string"
maple="a file path"
old=["red", "one", "maple"]
newList=map(eval, old)



More information about the Python-list mailing list