def getpath(data, path):
    """`getpath()` returns the value at a dot-separated getitem path.

    `data` can be a nested combination of dicts and arrays.  Each part of the
    path is interpreted as an integer if it looks like an integer.

    """
    for p in path.split('.'):
        try:
            p = int(p)
        except ValueError:
            pass
        data = data[p]
    return data