Why does types.MethodType complain too many arguments?

Viewed 750
>>> 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 am just wondering what were 2 arguments that I gave? I know one of them would be self, but what was the other one?

Of course, in this example, the correct way would be:

>>> types.MethodType(Foo.say, b)()
Foo say

But I am asking about the error of types.MethodType(f.say, b)(). I want to know why it complains

takes 1 positional argument but 2 were given

2 Answers
Related