
On Thu, Jan 21, 2021, at 18:48, Chris Angelico wrote:
Note that slicing is NOT easy. The proposed semantics for a reversed enumeration would make slicing extremely odd.
What proposed semantics? You were the one who posted a pure-python implementation that didn't bother to implement slicing. It's easy enough to add slicing to your Enumerated class concept, though. class Enumerated: def __init__(self, basis, indices=None): self.basis = basis self.indices = indices if indices is not None else range(len(basis)) def __getitem__(self, idx): if isinstance(idx, slice): return Enumerated(self.basis, indices=self.indices[idx]) else: return (self.indices[idx], self.basis[self.indices[idx]]) def __len__(self): return len(self.indices)