[Tutor] Re: question: how do you pass a function as argument for application?

Marcel Preda marcel@punto.it
Fri, 22 Sep 2000 13:21:57 +0200 (CEST)


I have send a stupid pice of code before.

Check this code:


>>> class C:
...     def f(self,a):
...             print(a)
...     def callMethod(self,method,arg):
...             method(arg)
... 
>>> d=C()
>>> d.callMethod(d.f,'dddddddd')
dddddddd
>>> def f2(a):  
...     print "I'm f2, and I'm printing ",a
... 
>>> d.callMethod(f2,'fff')
I'm f2, and I'm printing  fff



PM