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

alan.gauld@bt.com alan.gauld@bt.com
Wed, 27 Sep 2000 11:19:53 +0100


> Also, I am trying to do this in the object framwork:
> 
> class C:
> 	def method(sefl, arg):
> 		print self, arg
> 
> 	def methodApply(self, meth, arg):
> 	????	self.meth(arg)

>>> class foo:
...   def doit(self,arg):
...       print self, arg
...   def call(self,meth,arg):
...       meth(arg)
...
>>> f = foo()
>>> f.call(f.doit,'foobar')
<__main__.foo instance at 7f8140> foobar
>>>

Alan G.