[docs] [issue37145] collections.abc.MappingView mixins rely on undocumented _mapping
Raymond Hettinger
report at bugs.python.org
Tue Jun 4 04:39:59 EDT 2019
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
The __init__ method is public. Here is how to use ItemsView:
>>> from collections.abc import ItemsView
>>> d = dict(python='snake', ruby='gem', go='board game', c='speed of light')
>>> iv = ItemsView(d)
>>> ('python', 'snake') in iv
True
>>> list(iv)
[('python', 'snake'), ('ruby', 'gem'), ('go', 'board game'), ('c', 'speed of light')]
>>> len(iv)
4
>>> d['python'] = 'language'
>>> list(iv)
[('python', 'language'), ('ruby', 'gem'), ('go', 'board game'), ('c', 'speed of light')]
Note, there is no direct access to _mapping.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37145>
_______________________________________
More information about the docs
mailing list