python's OOP question
neoedmund
neoedmund at gmail.com
Sun Oct 15 21:39:14 EDT 2006
There's a program, it's result is "unexpected aaa", i want it to be
"expected aaa". how to make it work?
[code]
class C1(object):
def v(self, o):
return "expected "+o
class C2(object):
def v(self, o):
return "unexpected "+o
def m(self):
print self.v("aaa")
class C3(object):
def nothing(self):
pass
def test1():
o = C3()
setattr(o,"m",C2().m)
setattr(o,"v",C1().v)
o.m()
test1()
[/code]
More information about the Python-list
mailing list