13.11.1 __bases__类属性:
在第13.4.4 节中,我们概要地介绍了__bases__类属性,对任何(子)类,它是一个包含其父类(parent)的集合的元组。
# !/usr/bin/env python
# -*- coding: utf-8 -*-
class A(object): # define class A 定义类 A
pass
print A.__bases__
C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/eeeee/a8.py
(<type 'object'>,)
# !/usr/bin/env python
# -*- coding: utf-8 -*-
class A(object): # define class A 定义类 A
pass
print A.__bases__
class B(A): # subclass of A A 的子类
pass
print B.__bases__
C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/eeeee/a8.py
(<type 'object'>,)
(<class '__main__.A'>,)
# !/usr/bin/env python
# -*- coding: utf-8 -*-
class A(object): # define class A 定义类 A
pass
# print A.__bases__
class B(A): # subclass of A A 的子类
pass
# print B.__bases__
class C(B): # subclass of B (and indirectly, A) B 的子类(A 的间接子类)
pass
print C.__bases__
C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/eeeee/a8.py
(<class '__main__.B'>,)