Unexpected TypeError when using functools.partial with class instance methods
I'm performance testing and I'm maintaining legacy code that I'm relatively new to this, so bear with me..... I'm running into a `TypeError` when trying to use `functools.partial` to create a bound method for a class instance in Python 3.10. I've defined a class with a method that takes two parameters, and I'm trying to create a new function that only requires one of them. However, when I call the new function, I'm receiving an behavior. Here's the relevant code: ```python from functools import partial class MyClass: def multiply(self, x, y): return x * y my_instance = MyClass() partial_multiply = partial(my_instance.multiply, 2) result = partial_multiply(3) ``` This code is supposed to multiply `2` (the fixed argument) by `3` (the variable argument), but instead, I get: ``` TypeError: multiply() missing 1 required positional argument: 'y' ``` I thought `functools.partial` was supposed to bind the first argument, but it seems like it's not working as I expected. I’ve double-checked the method’s parameter list, and I’m sure that `y` is defined correctly. I also tried using a lambda function as a workaround, like this: ```python partial_multiply = lambda y: my_instance.multiply(2, y) ``` But I still want to understand why the `partial` function isn't working here. Can anyone explain what’s going wrong or suggest a solution? Am I missing something in how I’m using `functools.partial` with instance methods? Has anyone else encountered this? This is part of a larger web app I'm building. Any help would be greatly appreciated! The stack includes Python and several other technologies. Any examples would be super helpful.