[Tutor] tricky eval() problem
Marcus Goldfish
magoldfish at gmail.com
Fri Jul 22 21:41:36 CEST 2005
Here's a noodler I could use some help on: I need a class that can
call a user-specified function with arbitrary (unknown) parameter
lists. The trick, here, is that the user will dynamically specify the
funciton to invoke, and each function may differ in the number of
parameters passed during the call. For instance, suppose I define two
dummy functions with different calling signatures:
def foo1(a1, a2, a3):
...
def foo2(a1):
...
Then I seek a class, Caller
class Caller(object):
def execute(self, method, *parms):
# some way to execute method
That can be used in the following manner:
>> c = Caller();
>> c.execute("foo1", 8, 9, 10)
>> c.execute("foo2", "me")
Any tips on tackling this?
Thanks!
Marcus
More information about the Tutor
mailing list