【发布时间】:2020-01-17 20:38:52
【问题描述】:
我的父类中有一个构造函数,它接受四个参数。在我的子类中,我需要一个带有三个参数的类。在父类 I 中,第一个参数是长度。子类将有一个固定的长度。
我尝试了很多东西,但没有一个奏效。我添加的代码中的一个就是其中之一。
class X:
def __init__(self, len, speed, locate, direction):
self._len = len
self._speed = speed
self._locate = locate
self._direction = direction
from X import X
class Y(X):
def __int__(self, speed, locate, direction):
super().__init__(speed, locate, direction)
# one thing I've tried
self._len = 3.0
当我创建一个对象并尝试在其中传递三个参数时,表示我缺少方向。
【问题讨论】:
标签: python-3.x superclass