by animal_spirits · 4y ago · 0 comments
>>> class A:
... def foo(self):
... print('foo')
...
>>> class B:
... def bar(self):
... print('bar')
...
>>> A.bar = B.bar
>>> A().bar()
bar
Functions in python are objects as well. So while you can't do this to built in python types, there is a high likelihood you can do this to most objects in python libraries.