So, I know that in python everything is an โobjectโ, which means that it can be passed as an argument to a method. But I'm trying to figure out exactly how this works. So I tried the following example:
class A: def __init__(self): self.value = 'a' def my_method(self) print self.value class B: def __init__(self): self.values = 'b' def my_method(self, method): method() a = A() b = B() b.my_method(a.my_method)
Now it was first written to see how everything works. I know that I must, for example, check if the argument my_method callable. Now my question is:
How exactly is the method passed here? I mean the output I get is "a", so I assume that when the object method is passed as a parameter, so what is the actual object? In this case, when I pass a.my_method , an instance of a is also passed?
Bogdan
source share