This idea reminds me of numpy fancy indexing: that is, you can pass multiple indexes in at once. (See bumpy docs for details). I have no idea how that might translate to ducts (tulles are perfectly reasonable keys already) but I know I like it in numpy :-)
That being said, I can’t remember a use case where I would have used it with dicts. -CHB On Mon, Jun 6, 2022 at 11:04 AM Chris Angelico <ros...@gmail.com> wrote: > On Mon, 6 Jun 2022 at 18:02, Stephen J. Turnbull > <stephenjturnb...@gmail.com> wrote: > > > > David Mertz, Ph.D. writes: > > > > > These are all far too easy to do with comprehensions to merit new > methods > > > or stdlib functions. > > > > +1 > > > > > E.g., we might provide additional set-like operators for dicts. > > > > > >>> m - {'a'} # Would rightval be a set or dict though?! > > > >>> m & {'a', 'b'} # Same question, but set feels better, I think > > > > Why not "either"? Of course if you allow dicts, the question in both > > cases becomes whether the presence test is on keys or items. I think > > keys would be more frequently useful. > > > > Or even: Any iterable that yields keys? And then the presence test > would be defined entirely by keys (which makes the most sense). You > could subtract another dict, or a set, list, or anything. > > (You could even subtract the string "ab" to remove keys "a" and "b", > for what it's worth.) > > Of note: https://peps.python.org/pep-0584/#what-about-the-full-set-api > > """This PEP does not take a position on whether dicts should support > the full collection of set operators, and would prefer to leave that > for a later PEP (one of the authors is interested in drafting such a > PEP).""" > > So if you (or anyone) wants to move forward with this, I would > recommend (a) reading the notes in PEP 584, (b) reaching out to all > three authors of it to find out their current sentiment, and (c) > designing definitive semantics for the operators in question. I'd be > happy to help with the mechanics of getting a PEP written. > > ChrisA > _______________________________________________ > 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/ETCU6O7QGERUFQND5XRBLGHV5OT4CNT3/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Christopher Barker, PhD (Chris) 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/ZYQO7PE2SFTUC5YZB55GPS2HFKOOU7WG/ Code of Conduct: http://python.org/psf/codeofconduct/