On Aug 23, 7:25 pm, Gandalf <[EMAIL PROTECTED]> 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
>>>

Also, you can look up locals() and globals(), or getattr, if you do
this in a class.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to