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

Raymond Hettinger report at bugs.python.org
Tue Jun 4 13:56:06 EDT 2019


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Hit <submit> 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:
            def __init__(self, seq):
                    self._seq = seq
            def __len__(self):
                    return len(self._seq)
      
    >>> a = A('apple')
    >>> len(a)	  
    5

In this example, we document that class "A" can be called with a sequence and that len() can be called on instances of A.  The "dunder" methods are public, but are called and documented indirectly.  The "_seq" attribute is marked as private and would not be documented, since it is an implementation detail and not intended to be accessed directly.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37145>
_______________________________________


More information about the Python-bugs-list mailing list