I have simple class and object
class Cat():
def pet(self):
print('mrrrrrr')
puss = Cat()
Is there a builtin method for mechanism like this:
cat_sound = ???(puss, Cat.pet)
So I can separately pass and use object and its class function in nice way?
And I know that I can:
cat_sound = getattr(puss, 'pet')
cat_sound()
And:
catsound = getattr(puss, Cat.pet.__name__)
catsound()
Even this way what solves my problem but looks ugly:
catsound = getattr(puss, getattr(Cat.pet, '__name__'))
catsound()
EDIT: The another way is to call:
Cat.pet(puss)
But my question is still open :)
Cat.Miau(puss)do the job - but still, my question remain unanswered :D