[issue8488] Docstrings of non-data descriptors "ignored"

Torsten Landschoff report at bugs.python.org
Wed Apr 21 20:25:10 CEST 2010


New submission from Torsten Landschoff <t.landschoff at gmx.net>:

[I would assign priority minor to this, but the tracker won't let me]

I really like the online documentation features of python. However, I wonder about the output of the following simple example:

class Descriptor(object):
    """Doc of a non-data descriptor."""
    def __get__(self, instance, owner):
        return 42 if instance else self

class GetSetDescriptor(Descriptor):
    """Doc of a data-descriptor."""
    def __set__(self, instance, value):
        pass

class Demo(object):
    non_data = Descriptor()
    data = GetSetDescriptor()

help(Demo)


This results in

Help on class Demo in module __main__:

class Demo(builtins.object)
 |  Methods defined here:
 |  
 |  non_data = <__main__.Descriptor object>
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  data
 |      Doc of a data-descriptor.


I think the behaviour of pydoc wrt. the non_data descriptor is a bit out of line. I would have expected to find the docstring in the output here.

----------
components: Library (Lib)
files: doc.py
messages: 103880
nosy: torsten
severity: normal
status: open
title: Docstrings of non-data descriptors "ignored"
type: behavior
versions: Python 2.5, Python 2.6, Python 3.1, Python 3.2
Added file: http://bugs.python.org/file17027/doc.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8488>
_______________________________________


More information about the Python-bugs-list mailing list