python __双划线 参数

'''
>>> Class1.__doc__ # 类型帮助信息 'Class1 Doc.' 
>>> Class1.__name__ # 类型名称 'Class1' 
>>> Class1.__module__ # 类型所在模块 '__main__' 
>>> Class1.__bases__ # 类型所继承的基类 (<type 'object'>,) 
>>> Class1.__dict__ # 类型字典,存储所有类型成员信息。 <dictproxy object at 0x00D3AD70> 
>>> Class1().__class__ # 类型 <class '__main__.Class1'> 
>>> Class1().__module__ # 实例类型所在模块 '__main__' 
>>> Class1().__dict__ # 对象字典,存储所有实例成员信息。 {'i': 1234}
'''
class Ren(object):
    '''ok,it's crazy'''
    name = 'a human being'

    @staticmethod
    def look():
        return "ok"

class Men(Ren):

    sex = "male"

class Women(Ren):

    sex = "female"

class Baby(Women):

    sex = "children"

if __name__ == "__main__":

    r = Men()
    print(Ren.__dict__, "__dict__")
    print(Ren.__doc__, "__doc__")
    print(Men.__doc__, "__doc__")
    print(Ren.__bases__, "__bases__")
    print(Baby.__bases__[0].__bases__, "__bases__")
    print(Baby.__bases__[0].__dict__, "__dict__")
    print(Baby.__dict__, "__dict__")
    print(Men.__bases__[0](), "__bases__")
    print(Men.__name__, "__name__")
    print(r.__class__(), "__class__")
    print(r.__module__, "__class__")
    print(Men.__module__, "__class__")
    print(__file__)
{'__module__': '__main__', '__doc__': "ok,it's crazy", 'name': 'a human being', 'look': <staticmethod object at 0x000001FFD18E6518>, '__dict__': <attribute '__dict__' of 'Ren' objects>, '__weakref__': <attribute '__weakref__' of 'Ren' objects>} __dict__
ok,it's crazy __doc__
None __doc__
(<class 'object'>,) __bases__
(<class '__main__.Ren'>,) __bases__
{'__module__': '__main__', 'sex': 'female', '__doc__': None} __dict__
{'__module__': '__main__', 'sex': 'children', '__doc__': None} __dict__
<__main__.Ren object at 0x000001FFD1AD95C0> __bases__
Men __name__
<__main__.Men object at 0x000001FFD1AD96A0> __class__
__main__ __class__
__main__ __class__
D:/Projects/MxShop/tester.py

 

posted @ 2020-02-10 17:23  一心全意  阅读(298)  评论(0编辑  收藏  举报