I have a variable that points to a specific class instance method. Suppose there is a class called Clientthat implements a method get. To Clientcreate a single instance of the name Client, and the variable get_funcis assigned to the client get.
For example, suppose I have the following simplified code:
class Client:
def get(self):
print("This is the get function!")
client = Client()
get_func = client.get
I have little actual control over get_funcand how it is used, I can’t change that.
Now I want to make sure that it get_funchas Client.get.
The trivial test get_func == Client.getdoes not work, because it get_funcis a related method of a specific instance Client. I also cannot get the instance Clientdirectly (but the way to get the selfassociated method is a valid option if I knew how to do this)
source
share