def ordered_dir(klass):
    """
    List (most) attributes of the class including inherited ones, similar to `dir` build-in function,
    but respects order of attribute declaration as much as possible.
    This becomes unnecessary in Python 3.6+ as dicts became ordered.
    :param klass: class to list members for
    :return: a list of attributes declared in klass and its superclasses
    """
    attr_list = list()
    for c in reversed(klass.mro()):
        attr_list.extend(e for e in (
            c._ordered_class_members if hasattr(c, '_ordered_class_members') else c.__dict__)
            if e not in attr_list)
    return attr_list
def ordered_dir ( klass ) : attr_list = list ( ) for c in reversed ( klass . mro ( ) ) : attr_list . extend ( e for e in ( c . _ordered_class_members if hasattr ( c , '_ordered_class_members' ) else c . __dict__ ) if e not in attr_list ) return attr_list
List (most) attributes of the class including inherited ones, similar to `dir` build-in function,
    but respects order of attribute declaration as much as possible.
    This becomes unnecessary in Python 3.6+ as dicts became ordered.
    :param klass: class to list members for
    :return: a list of attributes declared in klass and its superclasses