diff options
author | Georg Brandl <georg@python.org> | 2010-10-15 16:03:02 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-10-15 16:03:02 (GMT) |
commit | f74cf77c8dbe75929d956cbeee7edc4ed24a12ba (patch) | |
tree | 155879cae40e6a6f243a1d67f2a85889167b8b03 /Doc/library | |
parent | 1f7fffb308390d10a2c6a4ec624f18cfeef97aeb (diff) | |
download | cpython-f74cf77c8dbe75929d956cbeee7edc4ed24a12ba.zip cpython-f74cf77c8dbe75929d956cbeee7edc4ed24a12ba.tar.gz cpython-f74cf77c8dbe75929d956cbeee7edc4ed24a12ba.tar.bz2 |
#7771: reference to documentation of dictview methods and operations.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/stdtypes.rst | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 0e2fd38..2232b66 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2208,34 +2208,11 @@ support membership tests: 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 - - Return the intersection of the dictview and the other object as a new set. - -.. describe:: dictview | other - - Return the union of the dictview and the other object as a new set. - -.. describe:: dictview - other - - Return the difference between the dictview and the other object (all elements - in *dictview* that aren't in *other*) as a new set. - -.. describe:: dictview ^ other - - 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. - -.. method:: dictview.isdisjoint(other) - - Return True if the view has no elements in common with *other*. Sets are - disjoint if and only if their intersection is the empty set. - +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.Set` are +available (for example, ``==``, ``<``, or ``^``). An example of dictionary view usage:: @@ -2265,6 +2242,8 @@ An example of dictionary view usage:: >>> # set operations >>> keys & {'eggs', 'bacon', 'salad'} {'bacon'} + >>> keys ^ {'sausage', 'juice'} + {'juice', 'eggs', 'bacon', 'spam'} .. _typememoryview: |