I've got an object that contains a large data table called _X
. Data examples of various lengths sit stacked end-to-end inside _X
, and a different table I've named _INDEX
encodes the mapping from example number -> range in _X
where that example lives.
What I want is to define a property called X
with __getitem__
and __setitem__
of its own such that I can use X[i,j]
to access the j
th element of the i
th example. This is to avoid having to write confusing verbose lines like self._X[self._INDEX[i]:self._INDEX[i+1]][j]
all over the place.
I could make a wrapper class with the right __getitem__
and __setitem__
and return that from my @property
function, but I'd rather not have to do that.