Variable Variable
Premshree Pillai
premshree.pillai at gmail.com
Sat Mar 19 04:38:59 EST 2005
On Sat, 19 Mar 2005 04:35:47 -0500, Leif K-Brooks <eurleif at ecritters.biz> wrote:
> 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']
I think what he wants to do is basically hold object names in a tuple
list, and then call the methods on those objects (while iterating or
whatever).
>
> for i in pc:
> stuff[i] = anyclass()
>
> stuff['a'].shutdown()
> stuff['b'].update()
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Premshree Pillai
http://www.livejournal.com/users/premshree/
More information about the Python-list
mailing list