On Fri, Sep 25, 2020 at 1:36 PM MRAB <pyt...@mrabarnett.plus.com> wrote:

> It currently doesn't support multiple indexes, so there's no distinction
> between one index that's a 2-tuple and 2 indexes: d[(1, 2)] == d[1, 2].
>

yeah, but one index isn't in a 1-tuple (much discussed on this thread), so
now we have the someone awkward (if consistent with the language):

obj[i] -->  __getitem__(i)
obj[i, j] -->  __getitem__((i, j))

if make a default an empty tuple, then we'll have:

obj[] -->  __getitem__(())
obj[i] -->  __getitem__(i)
obj[i, j] -->  __getitem__((i, j))

Or would the default only be used if there were one or more keyword
arguments? if so, we'd still have:

obj[keyword=k] -->  __getitem__((), keyword=k)
obj[i, keyword=k] -->  __getitem__(i, keyword=k)
obj[i, j, keyword=k] -->  __getitem__((i, j), keyword=k)

Which is, shall we say, not ideal.

-CHB







> Using an empty tuple as the default index isn't that bad, assuming
> you're going to allow a default.
> _______________________________________________
> 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/MN7MOV4EL5K4MWGGSAKWZYLFZQFTI3Y2/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
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/LAKGUS36CJ6M75QPANMX4RIWIYIC6NMH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to