超类继承自子类。 Coursera。他们疯了吗?

时间:2013-04-11 16:44:27

标签: python class inheritance subclass superclass

Learn to Program: Crafting Quality Code

截图

enter image description here 这是Coursera Learn to Program Crafting Quality Code Course的视频讲座。 所以在视频中有一个小测验。

class MyInt(int):
    # some code there

他们给出了4个答案,我需要选择正确的答案。 我一个接一个地选择我的答案,但最后他们说这是完全错误的答案。

  

int是MyInt的子类

这个问题Python: How do I make a subclass from a superclass?让我绝对正确地确认我是对的。

真相在哪里?

2 个答案:

答案 0 :(得分:1)

测验肯定有问题,问题中写的代码声明MyIntint子类(或等效地:int 1}}是MyInt超类,不是相反。

答案 1 :(得分:0)

如果从类继承,那个类就是超类。在示例中,int是超类(或基类),MyInt是子类。他们错了,就像你怀疑的那样。 ; - )

相关问题