【发布时间】:2011-09-15 08:50:27
【问题描述】:
我不明白为什么这个代码:
class A(object):
def __init__(self):
self.__value = 1
def get_value(self):
return self.__value
class B(A):
def __init__(self):
A.__init__( self )
self.__value = 2
b = B()
print b.get_value()
给 1,但不给 2。感谢您的帮助。
【问题讨论】:
-
stackoverflow.com/questions/165883/… 对此有很长的解释。
标签: python oop polymorphism