J
James Stroud
Hello All,
I did this:
py> class bob(object):
.... def __init__(self,**kwargs):
.... for fname,func in kwargs.items():
.... setattr(self, fname, lambda *args : func(*args))
....
py> def doit():
.... print "wuzzup?"
....
py> abob = bob(doit=doit)
py>
py> abob.doit()
wuzzup?
Much to my surprise, this works fine.
My questions:
1. What exactly is going on?
2. How can I get ref to self passed to doit() if I want it to? This:
abob.doit(abob)
seems like the hard way
Any ideas?
James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
http://www.jamesstroud.com/
I did this:
py> class bob(object):
.... def __init__(self,**kwargs):
.... for fname,func in kwargs.items():
.... setattr(self, fname, lambda *args : func(*args))
....
py> def doit():
.... print "wuzzup?"
....
py> abob = bob(doit=doit)
py>
py> abob.doit()
wuzzup?
Much to my surprise, this works fine.
My questions:
1. What exactly is going on?
2. How can I get ref to self passed to doit() if I want it to? This:
abob.doit(abob)
seems like the hard way
Any ideas?
James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
http://www.jamesstroud.com/