相关疑难解决方法(0)

Python super()参数:为什么不是super(obj)?

我试图了解何时以及如何正确使用Python中的super()(2.7.x或3.x)

>>> help(super)口译员告诉我如何称呼它:

class super(object)
 |  super(type) -> unbound super object
 |  super(type, obj) -> bound super object; requires isinstance(obj, type)
 |  super(type, type2) -> bound super object; requires issubclass(type2, type)
Run Code Online (Sandbox Code Playgroud)

我明白在Python3.x中,现在可以在类定义中使用super(),但我不明白为什么super(obj)不可能.或者super(self)在类定义中.

我知道必须有理由,但我找不到它.对我来说,这些线条相当于super(obj.__class__, obj)或者super(self.__class__, self)那些可以正常工作吗?

我认为super(obj)即使在Python 3.x中输入也是一个很好的捷径.

python inheritance super

27
推荐指数
2
解决办法
7165
查看次数

标签 统计

inheritance ×1

python ×1

super ×1