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

Side by Side Diff: Doc/library/stdtypes.rst

Issue 27544: documentiona of dict view types
Patch Set: Created 3 years, 7 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 .. XXX: reference/datamodel and this have quite a few overlaps! 1 .. XXX: reference/datamodel and this have quite a few overlaps!
2 2
3 3
4 .. _bltin-types: 4 .. _bltin-types:
5 5
6 ************** 6 **************
7 Built-in Types 7 Built-in Types
8 ************** 8 **************
9 9
10 The following sections describe the standard types that are built into the 10 The following sections describe the standard types that are built into the
(...skipping 4243 matching lines...) Expand 10 before | Expand all | Expand 10 after
4254 >>> del dishes['sausage'] 4254 >>> del dishes['sausage']
4255 >>> list(keys) 4255 >>> list(keys)
4256 ['spam', 'bacon'] 4256 ['spam', 'bacon']
4257 4257
4258 >>> # set operations 4258 >>> # set operations
4259 >>> keys & {'eggs', 'bacon', 'salad'} 4259 >>> keys & {'eggs', 'bacon', 'salad'}
4260 {'bacon'} 4260 {'bacon'}
4261 >>> keys ^ {'sausage', 'juice'} 4261 >>> keys ^ {'sausage', 'juice'}
4262 {'juice', 'sausage', 'bacon', 'spam'} 4262 {'juice', 'sausage', 'bacon', 'spam'}
4263 4263
4264 .. note::
4265 To check whether a variable is a view object, Python provides an
4266 :term:`abstract base class` for each type of view object, to allow instance
4267 and subclass checking with :func:`isinstance` and :func:`issubclass`. The
4268 :class:`collections.abc.KeysView`, :class:`collections.abc.ValuesViews`,
4269 and :class:`collections.abc.ItemsView` ABCs may be used to check for
4270 :meth:`dict.keys`, :meth:`dict.values` and :meth:`dict.items`, respectively.
4271 To check for any type of view object, use
4272 :class:`collections.abc.MappingView`.
4264 4273
4265 .. _typecontextmanager: 4274 .. _typecontextmanager:
4266 4275
4267 Context Manager Types 4276 Context Manager Types
4268 ===================== 4277 =====================
4269 4278
4270 .. index:: 4279 .. index::
4271 single: context manager 4280 single: context manager
4272 single: context management protocol 4281 single: context management protocol
4273 single: protocol; context management 4282 single: protocol; context management
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
4622 .. [2] As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0] ``, and 4631 .. [2] As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0] ``, and
4623 similarly for tuples. 4632 similarly for tuples.
4624 4633
4625 .. [3] They must have since the parser can't tell the type of the operands. 4634 .. [3] They must have since the parser can't tell the type of the operands.
4626 4635
4627 .. [4] Cased characters are those with general category property being one of 4636 .. [4] Cased characters are those with general category property being one of
4628 "Lu" (Letter, uppercase), "Ll" (Letter, lowercase), or "Lt" (Letter, titlecas e). 4637 "Lu" (Letter, uppercase), "Ll" (Letter, lowercase), or "Lt" (Letter, titlecas e).
4629 4638
4630 .. [5] To format only a tuple you should therefore provide a singleton tuple who se only 4639 .. [5] To format only a tuple you should therefore provide a singleton tuple who se only
4631 element is the tuple to be formatted. 4640 element is the tuple to be formatted.
OLDNEW
« 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+