def accumulateClassList(classObj, attr, listObj, baseClass=None):
 for base in classObj.__bases__:
  accumulateClassList(base, attr, listObj)
 if ((baseClass is None) or (baseClass in classObj.__bases__)):
  listObj.extend(classObj.__dict__.get(attr, []))

def accumulateClassList ( classObj , attr , listObj , baseClass = None ) : for base in classObj . __bases__ : accumulateClassList ( base , attr , listObj ) if ( ( baseClass is None ) or ( baseClass in classObj . __bases__ ) ) : listObj . extend ( classObj . __dict__ . get ( attr , [ ] ) )
accumulate all attributes of a given name in a class hierarchy into a single list .