apply for objects

Hahn S shahn at kits.cs.vu.nl
Fri Jun 16 04:44:29 EDT 2000


Ok, i have figured out how to use apply on methods. You just have to get
the method from the class and use the im_func in the apply. The first
argument must be the one which should be the self object.

Example:
>>> class D:
	def start(self, hoi, daar=100):
		print self.aap
		print hoi
		print daar


>>> d = D()
>>> d.aap = 'Artis is leuk'
>>> apply(D.start.im_func, (d, 'Hello World'))
Artis is leuk
Hello World
100

My own problem is solved. I hope someone cares :-)

Good luck with Python!
Sander Hahn



More information about the Python-list mailing list