Interesting problem - can it be done

Robin Becker robin at jessikat.fsnet.co.uk
Thu Aug 9 04:02:21 EDT 2001


>>> class A:
...     def func1(self):
...             return 1
...     def func2(self):
...             return 2
...     def func3(self):
...             return 3
...
>>> L=['func1','func3','func2']         #list of method names
>>> a = A()                             # create the object
>>> map(lambda x,a=a: apply(getattr(a,x),()), L)        #call
[1, 3, 2]                                               # the result
>>> 

-- 
Robin Becker



More information about the Python-list mailing list