在C#我会去:
myObj.base
Run Code Online (Sandbox Code Playgroud)
我有一个继承自date.datetime的Date类.Date类会覆盖__gt__(),__lt__()因此在使用<和>运算符时会调用它们.我不想使用这些覆盖 - 我想在Date实例上使用date.datetime方法.
使用super()以获得超对象.键入help(super)Python命令提示符.
从手册:
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)
| Typical use to call a cooperative superclass method:
| class C(B):
| def meth(self, arg):
| super(C, self).meth(arg)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4312 次 |
| 最近记录: |