I may get a chance to look carefully at this in a bit, but for now: On Tue, Sep 1, 2020 at 6:38 PM Ricky Teachey <ri...@teachey.org> wrote:
> Sorry for all the replies but I'm honestly very unsure how do this > correctly under Steven's proposal. > That's OK. It's going to be tricky, and keeping backward compatibility makes that necessary. And, in fact, the current sytax is pretty tricky as well. Say you want to make a class that takes multiple indices -- like a Mtraix, for instance. your __getitem__ looks like: def __getitem__(self, index): as they all do. But what might index be? It could be one of: * an object with an __index__ method -- so a single index, simple * a slice object * a tuple, where each item in the tuple could be both of the above. Or, of course, it could be invalid, and you need to raise an Exception with a meaningful message. So there's a lot of logic there and we haven't even started in the keywords :-) But that's all OK, as the number of people that need to write these methods is small, and the number of people that can use the feature is large. -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ 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/2ORJJKUTW2LVCES52Q5LCCH6T3DTJFWL/ Code of Conduct: http://python.org/psf/codeofconduct/