• 调用父类和子类的__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)
    
    
    调用子类的__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'>
  • 相关阅读:
    IfcRoot
    IfcMaterial
    IfcDirection
    IfcAxis2Placement3D
    IfcBeam属性
    osg::Node源码
    不规则形状的Ifc构件顶点坐标获取
    不规则的Ifc构件顶点提取方法
    osg::Group源码
    Qt 图片缩放参数计算
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348366.html
Copyright © 2020-2023  润新知