# -*- coding: utf-8 -*- class test(object): pass class test1(test): pass class test2(test1): pass print test2.__bases__ print type(test2.__bases__[0]) print test2.__bases__[0].__bases__ print getattr(test2.__bases__[0], ‘__bases__‘) print ‘-‘ * 10 def fa(ch): f_list = getattr(ch, ‘__bases__‘) for f in f_list: print f fa(f) fa(test2)
或者:
import inspect print inspect.getmro(test2)
涉及知识:python 自省
详细的好文章:http://www.cnblogs.com/huxi/archive/2011/01/02/1924317.html
<END>