class Test:
def func():
print( func )
test1 = Test()
test2 = Test()
test1.func() #TypeError: fun1() takes no arguments (1 given)
test2.newfunc = Test.func
test2.newfunc()#It goes well
# update part
def foo(self):
pass
Test.foo = foo
test1.foo # it is bound method
test2.foo = foo
test2.foo # it is function
# end
Is there any difference between the two ways ? Thanks.
# update part
def foo(self):
pass
Test.foo = foo
test1.foo # it is bound method
test2.foo = foo
test2.foo # it is function
# end
请注意,重要的是,检索应在班级而不是班级进行。