class SearchEngineBase(object):
def __init__(self):
print '111111'
class SimpleEngine(SearchEngineBase):
def __init__(self):
print '222222222'
# super(SimpleEngine, self).__init__()
# self.__id_to_texts = {}
x=SimpleEngine()
print x
print type(x)
调用子类的__init__:
C:Python27python.exe "C:/Users/TLCB/PycharmProjects/untitled2/python study/t8.py"
222222222
<__main__.SimpleEngine object at 0x020D2670>
<class '__main__.SimpleEngine'>
调用父类的__init__:
class SearchEngineBase(object):
def __init__(self):
print '111111'
class SimpleEngine(SearchEngineBase):
def __init__(self):
# print '222222222'
super(SimpleEngine, self).__init__()
self.__id_to_texts = {}
x=SimpleEngine()
print x
print type(x)
C:Python27python.exe "C:/Users/TLCB/PycharmProjects/untitled2/python study/t8.py"
111111
<__main__.SimpleEngine object at 0x021026B0>
<class '__main__.SimpleEngine'>