On Thu, 27 Aug 2020 at 16:21, David Mertz <me...@gnosis.cx> wrote: > > On Thu, Aug 27, 2020 at 10:51 AM Stephen J. Turnbull > <turnbull.stephen...@u.tsukuba.ac.jp> wrote: >> >> They're going to get one, is my reading of the "named indicies" >> thread. That is, it looks to me very likely that index notation >> (`x[i]`) is going to support keyword arguments (`x[i, k=v]`). If so, >> that's going to be a natural way to support a `default` argument. I >> imagine some people will choose it because they like it, and if there >> are enough people who do there will be pressure for it to be TOOWTDI. > > > I support named indices. But I strongly oppose using them in list, tuple, or > dict themselves. So `mylist[99, default=4]` would still be a syntax error > (or maybe a different exception). > > I only want named indices for data structures where a clear and compelling > use is demonstrated (like xarray). But allowing them syntactically allows > third parties to play around in their own classes to see if they are helpful.
Agreed - allowing keywords in subscripts is OK (I'm personally ambivalent about the value of it, but if people want it, sure). But only for 3rd party classes. No-one has come up with a good use case for allowing them in existing builtin classes, and I'm -1 on doing so without a strong use case. Furthermore, I'd be very, very strongly opposed to having x[i, default=d] be a way of supplying a default result if i isn't present in *any* subscriptable class, and particularly in dict as an equivalent for x.get(i, d). It's redundant, confusing, and unlike any other language I'm familiar with (all IMO, if that's not obvious...). Paul _______________________________________________ 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/TWJC64L7S5TRI6YPE3OJ2IRDDWTIWQ3C/ Code of Conduct: http://python.org/psf/codeofconduct/