Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 18b88fe

Browse filesBrowse files
[3.12] gh-111622: Fix doc for items views (GH-112051) (#112052)
They are set-like even when some values are not hashable, but work even better when all are. (cherry picked from commit e31d65e) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
1 parent d34650e commit 18b88fe
Copy full SHA for 18b88fe

File tree

Expand file treeCollapse file tree

1 file changed

+8
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-5
lines changed

‎Doc/library/stdtypes.rst

Copy file name to clipboardExpand all lines: Doc/library/stdtypes.rst
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,14 +4752,17 @@ support membership tests:
47524752

47534753
.. versionadded:: 3.10
47544754

4755-
Keys views are set-like since their entries are unique and :term:`hashable`. If all
4756-
values are hashable, so that ``(key, value)`` pairs are unique and hashable,
4757-
then the items view is also set-like. (Values views are not treated as set-like
4755+
Keys views are set-like since their entries are unique and :term:`hashable`.
4756+
Items views also have set-like operations since the (key, value) pairs
4757+
are unique and the keys are hashable.
4758+
If all values in an items view are hashable as well,
4759+
then the items view can interoperate with other sets.
4760+
(Values views are not treated as set-like
47584761
since the entries are generally not unique.) For set-like views, all of the
47594762
operations defined for the abstract base class :class:`collections.abc.Set` are
47604763
available (for example, ``==``, ``<``, or ``^``). While using set operators,
4761-
set-like views accept any iterable as the other operand, unlike sets which only
4762-
accept sets as the input.
4764+
set-like views accept any iterable as the other operand,
4765+
unlike sets which only accept sets as the input.
47634766

47644767
An example of dictionary view usage::
47654768

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.