Variable Variable

Leif K-Brooks eurleif at ecritters.biz
Sat Mar 19 10:35:47 CET 2005


Tanteauguri wrote:
> Hi List, is there in python a variable variable like in PHP ($$var)?
> 
> What I want to do is something like that:
> 
> pc=["a","b","c"]
> 
> for i in pc:
>     i = anyclass()
> 
> a.shutdown()
> b.update()

Use a dictionary:

stuff = {}
pc = ['a', 'b', 'c']

for i in pc:
     stuff[i] = anyclass()

stuff['a'].shutdown()
stuff['b'].update()



More information about the Python-list mailing list