Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Unified Diff: Doc/library/stdtypes.rst

Issue 27544: documentiona of dict view types
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -4261,6 +4261,15 @@ An example of dictionary view usage::
>>> keys ^ {'sausage', 'juice'}
{'juice', 'sausage', 'bacon', 'spam'}
+.. note::
+ To check whether a variable is a view object, Python provides an
+ :term:`abstract base class` for each type of view object, to allow instance
+ and subclass checking with :func:`isinstance` and :func:`issubclass`. The
+ :class:`collections.abc.KeysView`, :class:`collections.abc.ValuesViews`,
+ and :class:`collections.abc.ItemsView` ABCs may be used to check for
+ :meth:`dict.keys`, :meth:`dict.values` and :meth:`dict.items`, respectively.
+ To check for any type of view object, use
+ :class:`collections.abc.MappingView`.
.. _typecontextmanager:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+