def maybe_get(obj, i):
    """

    :param obj: object
    :param i: the index
    :return: the i-th item if the `obj` instantiates the __getitem__ function
    """
    return obj[i] if hasattr(obj, "__getitem__") else obj