Store variable name in another variable

Laurent Pointal laurent.pointal at limsi.fr
Thu Apr 26 15:09:22 CEST 2007


loial a écrit :
> I need to store a list of variable names in a dictionary or list. I
> then later need to retrieve the names of the variables and get the
> values from the named variables. The named variables will already have
> been created and given a value.

"Named variables will already have been created"... in what namespace ?

Store a list of names -> dict/list (see tutorial)

Then,
use namespace.name
or  getattr(namespace,"name")
or  locals()["name"]
or  globals()["name"]





More information about the Python-list mailing list