Correct way to write __repr__ function with inheritance

前端 未结 2 2182
半阙折子戏
半阙折子戏 2021-02-07 06:34

I\'m experimenting with OOP python and I wasn\'t sure about the __repr__ function inheritance. Since the parent class function looked like this:

def         


        
2条回答
  •  爱一瞬间的悲伤
    2021-02-07 07:08

    Yes - - it is not just "ok", but it is what is more practical in almost every project and class hierarchy.

    Actually, this is almost a perfect "text book example" of when to use class inheritance, and just let the code in the superclasses be reused.

提交回复
热议问题