[issue37145] collections.abc.MappingView mixins rely on undocumented _mapping

2019-06-04 Thread Geoffrey Sneddon
Geoffrey Sneddon added the comment: Like, where in the documentation can I learn that MappingView's initializer takes an argument "mapping"? -- ___ Python tracker ___

[issue37145] collections.abc.MappingView mixins rely on undocumented _mapping

2019-06-04 Thread Geoffrey Sneddon
Geoffrey Sneddon added the comment: You've missed my point: the arguments that MappingView.__init__ takes are undocumented. Nowhere mentions class MappingView(mapping), as I would expect from how initializers are documented elsewhere. -- ___

[issue37145] collections.abc.MappingView mixins rely on undocumented _mapping

2019-06-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: Hit too early. In Python, the norm is that the class name is documented. When you call the class, the __init__() method gets called automatically (as documented in the language reference and in the tutorial). For example: >>> class A:

[issue37145] collections.abc.MappingView mixins rely on undocumented _mapping

2019-06-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Then I guess what I consider a bug is "__init__ is undocumented". No, this just how Python works. -- ___ Python tracker ___

[issue37145] collections.abc.MappingView mixins rely on undocumented _mapping

2019-06-04 Thread Geoffrey Sneddon
Geoffrey Sneddon added the comment: Then I guess what I consider a bug is "__init__ is undocumented". -- ___ Python tracker ___

[issue37145] collections.abc.MappingView mixins rely on undocumented _mapping

2019-06-04 Thread Raymond Hettinger
Raymond Hettinger 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)

[issue37145] collections.abc.MappingView mixins rely on undocumented _mapping

2019-06-03 Thread Geoffrey Sneddon
Geoffrey Sneddon added the comment: How do you use ItemsView without: * relying on __init__ and _mapping, which are both private implementation details, or * reimplementing __len__, __contains__, and __iter__? Given you can't use the mixin implementations of __len__, __contains__, and

[issue37145] collections.abc.MappingView mixins rely on undocumented _mapping

2019-06-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: The _mapping attribute is a private implementation detail and should remain undocumented. A user of mapping views creates that attribute via the __init__() method. In contrast, _from_iterable is explicitly meant to be overridden because it is the only

[issue37145] collections.abc.MappingView mixins rely on undocumented _mapping

2019-06-03 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +rhettinger versions: -Python 3.5, Python 3.6 ___ Python tracker ___ ___

[issue37145] collections.abc.MappingView mixins rely on undocumented _mapping

2019-06-03 Thread Geoffrey Sneddon
New submission from Geoffrey Sneddon : The mixin methods on MappingView and its subclasses all rely on the undocumented MappingView._mapping (set in the undocumented MappingView.__init__). This should probably be documented at least insofar as Set._from_iterable is. -- assignee: