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
Note that what's important is that the retrieval should take place in class instead of instance.
test2.newfunc()works...