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

前端 未结 4 1789
轻奢々
轻奢々 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:58

    A while back I wondered about the same "feature" in Perl on PerlMonks, and the general consensus was that while it works (as it does in Python) you should not be doing things that way.

提交回复
热议问题