Referencing vars, methods and classes by name
Gabriel Genellina
gagsl-py at yahoo.com.ar
Thu Feb 8 03:44:36 EST 2007
En Thu, 08 Feb 2007 05:29:23 -0300, Paul Rubin
<"http://phr.cx"@NOSPAM.invalid> escribió:
> "Sagari" <boyandin at gmail.com> writes:
>> $a = ''b';
>> $obj->$a(); // call method b() of the instance $obj
>>
>> What is the Python way of performing the same indirections?
>
> For your last example we could say
>
> obj.getattr(a)()
>
> but even that is a bit ugly, depending.
Surely you meant to say getattr(obj, a)()
--
Gabriel Genellina
More information about the Python-list
mailing list