def path_types(obj, path):
    """
    Given a list of path name elements, return anew list of [name, type] path components, given the reference object.
    """
    result = []
    #for elem in path[:-1]:
    cur = obj
    for elem in path[:-1]:
        if ((issubclass(cur.__class__, MutableMapping) and elem in cur)):
            result.append([elem, cur[elem].__class__])
            cur = cur[elem]
        elif (issubclass(cur.__class__, MutableSequence) and int(elem) < len(cur)):
            elem = int(elem)
            result.append([elem, cur[elem].__class__])
            cur = cur[elem]
        else:
            result.append([elem, dict])
    try:
        try:
            result.append([path[-1], cur[path[-1]].__class__])
        except TypeError:
            result.append([path[-1], cur[int(path[-1])].__class__])
    except (KeyError, IndexError):
        result.append([path[-1], path[-1].__class__])
    return result
def path_types ( obj , path ) : result = [ ] cur = obj for elem in path [ : - 1 ] : if ( ( issubclass ( cur . __class__ , MutableMapping ) and elem in cur ) ) : result . append ( [ elem , cur [ elem ] . __class__ ] ) cur = cur [ elem ] elif ( issubclass ( cur . __class__ , MutableSequence ) and int ( elem ) < len ( cur ) ) : elem = int ( elem ) result . append ( [ elem , cur [ elem ] . __class__ ] ) cur = cur [ elem ] else : result . append ( [ elem , dict ] ) try : try : result . append ( [ path [ - 1 ] , cur [ path [ - 1 ] ] . __class__ ] ) except TypeError : result . append ( [ path [ - 1 ] , cur [ int ( path [ - 1 ] ) ] . __class__ ] ) except ( KeyError , IndexError ) : result . append ( [ path [ - 1 ] , path [ - 1 ] . __class__ ] ) return result
Given a list of path name elements, return anew list of [name, type] path components, given the reference object.