variable variables
David Humphreys
badassgeek at earthlink.net
Mon Dec 11 06:40:43 EST 2000
You could:
exec "print test%d" % (var1)
> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of pyth at relax.dk
> Sent: Monday, December 11, 2000 2:35 AM
> To: python-list at python.org
> Subject: RE: variable variables
>
>
> > I guess you want to be able to have multiple references to the same
> > variable, and that you want to be able to change the value of that
> > variable in such a way that all references refer to the same new value.
>
> > /Mikael
>
> Sorry Mikael, for using your time... I should have been more specific...
> What i was thinking of, was something like this:
>
> test1 = 'test text 1';
> test2 = 'test text 2';
>
> var1 = 1
> var2 = 2
>
> print test{var1};
>
> This should print: 'test text 1'
> This example doesn't work, but is close how you would do it in php :o)
>
> Thanx for tryin' Mikael :o)
>
> /Dan Larsen
>
>
>
>
> --
> http://www.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list