On Wed, 2 Sep 2020 at 05:20, Christopher Barker <python...@gmail.com> wrote:
> 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.

And this is the reason why personally I would prefer to add a new
dunder with more defined semantics. This poor sod of a method has
already a lot to handle, exactly because it's behaving nothing like a
function. As a programmer developing that method, you are essentially
doing the job of the interpreter.

> 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.

True but there's a point where one should question if the direction
getitem has taken is the right one.



-- 
Kind regards,

Stefano Borini
_______________________________________________
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/6X6WNL4NDKGTMOWLGEQG6CZDVO2ER56F/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to