【发布时间】:2011-01-20 12:58:18
【问题描述】:
我有两个类 A 和 B,A 是 B 的基类。
我读到 Python 中的所有方法都是虚拟的。
那么如何调用基类的方法,因为当我尝试调用它时,派生类的方法会按预期调用?
>>> class A(object):
def print_it(self):
print 'A'
>>> class B(A):
def print_it(self):
print 'B'
>>> x = B()
>>> x.print_it()
B
>>> x.A ???
【问题讨论】: