Re: Calling class method by name passed in variable

2008-05-23 Thread Sagari
Thanks to everyone for the advice. In fact, since all the called methods trap necessary exceptions, I see no big problems with that. With all respect, Konstantin -- http://mail.python.org/mailman/listinfo/python-list

Calling class method by name passed in variable

2008-05-22 Thread Sagari
Greetings, Can someone suggest an efficient way of calling method whose name is passed in a variable? Given something like: class X: #... def a(self): # ... def b(self): # ... #... x = X() #... v = 'a' How do I call the method of x whose name is stored in v? PHP code for this would be:

Re: Referencing vars, methods and classes by name

2007-02-09 Thread Sagari
> For your other examples there are gross hacks using the dictionaries > that represent the local and global symbol tables, so we translate > your examples fairly directly, but stylistically we'd usually stay > away from that kind of thing. Thanks to everyone for all the comments. I am migrating f

Re: Referencing vars, methods and classes by name

2007-02-08 Thread Sagari
Quite forgot to add the obvious example (in PHP): $a = 'b'; $obj =& new $a(); // instantiating class b() -- http://mail.python.org/mailman/listinfo/python-list

Referencing vars, methods and classes by name

2007-02-08 Thread Sagari
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 insta