def obj_index_getter(key):
    """Get a callable that extracts a key form an object."""
    return lambda obj: (
        getattr(obj, "__getitem__", None) or getattr(obj, "__getattribute__")
    )(key)