Generate variables at run time?
Erik Max Francis
max at alcyone.com
Wed Jan 8 06:43:38 EST 2003
Byron Morgan wrote:
> Is there any way in Python to generate a new variable name based on
> data? I
> have tried the eval() function, but this gets rejected, if the
> variable
> doesn't already exist.
You could use exec. Probably if you find yourself doing this a lot,
you're better off using 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
/ \ The opinion of the strongest is always the best.
\__/ Jean de la Fontaine
PyUID / http://www.alcyone.com/pyos/uid/
A module for generating "unique" IDs in Python.
More information about the Python-list
mailing list