summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-11-17 21:47:41 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-11-17 21:47:41 (GMT)
commitce0506ced3f04e751eb841111b43ce9c29fcdd07 (patch)
treee03951cc2d2ee0964e67ac2ff7f2d62f82fd9b1b /Doc
parent276c3718e3aa3954026297a9effcd952ca695aa7 (diff)
downloadcpython-ce0506ced3f04e751eb841111b43ce9c29fcdd07.zip
cpython-ce0506ced3f04e751eb841111b43ce9c29fcdd07.tar.gz
cpython-ce0506ced3f04e751eb841111b43ce9c29fcdd07.tar.bz2
rephrase dict view docs
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/stdtypes.rst15
1 files changed, 6 insertions, 9 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 04dd888..f0d51e2 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1881,8 +1881,7 @@ Dictionary view objects
The objects returned by :meth:`dict.keys`, :meth:`dict.values` and
:meth:`dict.items` are *view objects*. They provide a dynamic view on the
dictionary's entries, which means that when the dictionary changes, the view
-reflects these changes. The keys and items views have a set-like character
-since their entries
+reflects these changes.
Dictionary views can be iterated over to yield their respective data, and
support membership tests:
@@ -1910,8 +1909,11 @@ support membership tests:
items (in the latter case, *x* should be a ``(key, value)`` tuple).
-The keys and items views also provide set-like operations ("other" here refers
-to another dictionary view or a set):
+Keys views are set-like since their entries are unique and hashable. If all
+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.) Then these set operations are
+available ("other" refers either to another view or a set):
.. describe:: dictview & other
@@ -1931,11 +1933,6 @@ to another dictionary view or a set):
Return the symmetric difference (all elements either in *dictview* or
*other*, but not in both) of the dictview and the other object as a new set.
-.. warning::
-
- Since a dictionary's values are not required to be hashable, any of these
- four operations will fail if an involved dictionary contains such a value.
-
An example of dictionary view usage::