In Python, can you call an instance method of class A, but pass in an instance of class B?

前端 未结 4 1793
轻奢々
轻奢々 2020-12-19 07:57

In the interest of reusing some existing code that was defined as an instance method of a different class, I was tying to do something like the following:

cl         


        
4条回答
  •  忘掉有多难
    2020-12-19 08:38

    Looks like this works:

    Foo.hello.im_func(bar)
    

    Hello, I am Bar.

    I guess I need to read a this little harder...

提交回复
热议问题