#!/usr/local/bin/python2 import itertools chain_from_iterable = itertools.chain.from_iterable class A(object): pass class B(A): pass class C(object): pass class D(C): pass class E(A, C): pass for ancestor in chain_from_iterable(base.__mro__ for base in [E,B]): print ancestor