Why do .MethodType types complain about too many arguments?
>>> import types
>>> class Foo:
... def say(self):
... print("Foo say")
...
>>> class Bar:
... def say(self):
... print("Bar say")
...
>>> f = Foo()
>>> b = Bar()
>>> types.MethodType(f.say, b)()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: say() takes 1 positional argument but 2 were given
I'm just wondering what were the 2 arguments I gave? I know that one of them will be self, but what was the other?
Of course, in this example the correct way is:
>>> types.MethodType(Foo.say, b)()
Foo say
But I am asking for an error types.MethodType(f.say, b)(). I want to know why he complains
takes 1 positional argument, but 2 are given