A variables variables
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Tue Aug 26 04:52:30 EDT 2008
castironpi a écrit :
> On Aug 23, 7:25 pm, Gandalf <goldn... at gmail.com> wrote:
>> how can I declare a variable with another variable name?
>>
>> for example I will use PHP:
>>
>> $a= "hello";
>>
>> $a_hello="baybay";
>>
>> print ${'a_'.$a) //output: baybay
>>
>> how can i do it with no Arrays using python
>>
>> thanks!
>
> Here's one idea.
>
>>>> a= 'hello'
>>>> a_hello= 'bayb'
>>>> print eval( 'a_'+ a )
> bayb
Please avoid this kind of yucky ugly hacks.
More information about the Python-list
mailing list