On Mon, Aug 17, 2020, at 14:00, Christopher Barker wrote:
> From an implementation perspective, the [] operator is another way to 
> call __getitem__ and __setitem__. And from that perspective, why not 
> have it act like a function call: no arguments, positional arguments, 
> keyword arguments, the whole shebang.
> 
> But from a language design perspective, the [] operator is a way to 
> "index" a container -- get part of the container's contents. And from 
> this perspective, no index makes no sense.

I think it makes perfect sense. Remember that numpy *currently* has a concept 
of "no index" [an empty tuple is used for this], it results in a view of the 
whole array, or the content as a scalar for a 0-dimensional array.

[I've occasionally been tempted to try the same thing on ctypes objects, 
incidentally, I think it might be useful to make obj[] equivalent to obj.value]
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/G4WY4R5N5BAEKCR4ECTBQLXPT33TMD4B/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to