Referencing vars, methods and classes by name

Sagari boyandin at gmail.com
Thu Feb 8 03:18:46 EST 2007


Greetings,

Sorry for a newbiw question: what is a most elegant and/or effective
way to reference vars, methods and classes by their names in Python?

To illustrate, PHP code:

$a = ''b';
$$a = $something; // assign to $b
$$a($p1); // call function b($p1)
$obj->$a(); // call method b() of the instance $obj

What is the Python way of performing the same indirections?

References to online docs/articles related to the subject are very
welcome.

Thank you!

Konstantin




More information about the Python-list mailing list