Making variable from a variable

Erik Max Francis max at alcyone.com
Thu Oct 9 05:18:42 EDT 2003


"Polerio Babao Jr.II" wrote:

> I don't know if this question is easy or not but one thing I can say
> is
> I haven't encountered this problem yet in my entire python life. I
> just opened
> this question to the public because I've solved this kind of problem
> already
> before in my PHP life long time ago. I just want to know if it's also
> possible in Python.
> Any idea? Thanks.

It is, with eval/exec.  It's far more likely, though, that in Python a
better approach to this sort of problem would be to use a dictionary.

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Custom reconciles us to everything.
\__/  Edmund Burke




More information about the Python-list mailing list