Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 615537e

Browse files
authored
gh-96408: Document difference between set-like view and sets. (GH-96439)
1 parent 29f1b0b commit 615537e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Doc/library/stdtypes.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -4694,7 +4694,9 @@ values are hashable, so that ``(key, value)`` pairs are unique and hashable,
46944694
then the items view is also set-like. (Values views are not treated as set-like
46954695
since the entries are generally not unique.) For set-like views, all of the
46964696
operations defined for the abstract base class :class:`collections.abc.Set` are
4697-
available (for example, ``==``, ``<``, or ``^``).
4697+
available (for example, ``==``, ``<``, or ``^``). While using set operators,
4698+
set-like views accept any iterable as the other operand, unlike sets which only
4699+
accept sets as the input.
46984700

46994701
An example of dictionary view usage::
47004702

@@ -4726,6 +4728,8 @@ An example of dictionary view usage::
47264728
{'bacon'}
47274729
>>> keys ^ {'sausage', 'juice'}
47284730
{'juice', 'sausage', 'bacon', 'spam'}
4731+
>>> keys | ['juice', 'juice', 'juice']
4732+
{'juice', 'sausage', 'bacon', 'spam', 'eggs'}
47294733

47304734
>>> # get back a read-only proxy for the original dictionary
47314735
>>> values.mapping

0 commit comments

Comments
 (0)