Python Method overriding, does signature matter?

后端 未结 6 1144
轮回少年
轮回少年 2020-12-04 15:11

Lets say I have

class Super():
  def method1():
    pass

class Sub(Super):
  def method1(param1, param2, param3):
      stuff

Is this corr

6条回答
  •  佛祖请我去吃肉
    2020-12-04 15:38

    Python will allow this, but if method1() is intended to be executed from external code then you may want to reconsider this, as it violates LSP and so won't always work properly.

提交回复
热议问题