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)
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ZV3DG5HEM34WY2C5ETO744XBP4SAQENU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to