use set notation for repr of dict_keys?

Marco Sulla Marco.Sulla.Python at gmail.com
Wed Feb 24 02:59:30 EST 2021


On Wed, 24 Feb 2021 at 06:29, Random832 <random832 at fastmail.com> wrote:
> I was surprised, though, to find that you can't remove items directly from the key set, or in general update it in place with &= or -= (these operators work, but give a new set object).

This is because they are a view. Changing the key object means you
will change the underlying dict. Probably not that you want or expect.
You can just "cast" them into a "real" set object.

There was a discussion to implement the whole Set interface for dicts.
Currently, only `|` is supported.


More information about the Python-list mailing list