diff options
author | Piotr Kaznowski <piotr@kazno.dev> | 2022-08-31 21:23:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-31 21:23:52 (GMT) |
commit | 615537e62f0a49f6888ac27046bd8de965512d9d (patch) | |
tree | 5ee65316dee2ae74043fe81957c833c65e5f0ec2 | |
parent | 29f1b0bb1ff73dcc28f0ca7e11794141b6de58c9 (diff) | |
download | cpython-615537e62f0a49f6888ac27046bd8de965512d9d.zip cpython-615537e62f0a49f6888ac27046bd8de965512d9d.tar.gz cpython-615537e62f0a49f6888ac27046bd8de965512d9d.tar.bz2 |
gh-96408: Document difference between set-like view and sets. (GH-96439)
-rw-r--r-- | Doc/library/stdtypes.rst | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 2c02186..f68cf46 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4694,7 +4694,9 @@ values are hashable, so that ``(key, value)`` pairs are unique and hashable, then the items view is also set-like. (Values views are not treated as set-like since the entries are generally not unique.) For set-like views, all of the operations defined for the abstract base class :class:`collections.abc.Set` are -available (for example, ``==``, ``<``, or ``^``). +available (for example, ``==``, ``<``, or ``^``). While using set operators, +set-like views accept any iterable as the other operand, unlike sets which only +accept sets as the input. An example of dictionary view usage:: @@ -4726,6 +4728,8 @@ An example of dictionary view usage:: {'bacon'} >>> keys ^ {'sausage', 'juice'} {'juice', 'sausage', 'bacon', 'spam'} + >>> keys | ['juice', 'juice', 'juice'] + {'juice', 'sausage', 'bacon', 'spam', 'eggs'} >>> # get back a read-only proxy for the original dictionary >>> values.mapping |