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/

Reply via email to