标签:style class blog code http color
# -*- 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>
python - 回溯继承树 - 自己实现,布布扣,bubuko.com
标签:style class blog code http color
原文地址:http://www.cnblogs.com/kevin922/p/3807757.html