Convert the contents of a string into name of variable

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sun Mar 27 20:25:31 CEST 2005


Erwan VITIERE a écrit :
> Hello,
> I want to convert the contents of a string into name of variable.
> For example:
> 
> var1="toto"
> ...
> toto=5
> print toto 
> 
> 

exec "toto = 5"
print toto

But I would use another solution if possible.



More information about the Python-list mailing list