Confused about bound functions

Theodore D. Sternberg strnbrg at c532352-a.frmt1.sfba.home.com
Sat Aug 18 18:49:02 CEST 2001


Why do I need to pass in a self argument, in the
last line of the following program?

------------------------
class C:
    pass

c = C()
cmd = 'def foo(self): print "I am foo"'
exec cmd in c.__dict__

c.foo(c)
------------------------

I'd like to be able to say simply "c.foo()".
How can I arrange for that?

Theodore Sternberg
Fremont, Cal. USA



More information about the Python-list mailing list