Reference to self not passed to member function

wittempj@hotmail.com martin.witte at gmail.com
Fri May 6 18:46:19 EDT 2005


I think it is more clear to rephrase your code as:
-#!/usr/bin/env python
-class bob(object):
-    def __init__(self,**kwargs):
-        print kwargs
-        for fname,func in kwargs.items():
-            setattr(self, fname, lambda *args : func(*args))
-
-def doit():
-    print "wuzzup?"
-
-
-abob = bob(sayyoudo=doit)
-
-abob.sayyoudo()
outpu is now:
martin at ubuntu:~$ ./test.py
{'sayyoudo': <function doit at 0xb7dfcdf4>}
wuzzup?
martin at ubuntu:~$

so property sayyoudo points to method doit




More information about the Python-list mailing list