how to inherit docstrings?
Carl Banks
pavlovevidence at gmail.com
Fri Jun 10 17:46:06 EDT 2011
On Friday, June 10, 2011 2:51:20 AM UTC-7, Steven D'Aprano wrote:
> On Thu, 09 Jun 2011 20:36:53 -0700, Carl Banks wrote:
> > Put it this way: if Python doesn't automatically inherit docstrings, the
> > worst that can happen is missing information. If Python does inherit
> > docstrings, it can lead to incorrect information.
>
> This is no different from inheriting any other attribute. If your class
> inherits "attribute", you might get an invalid value unless you take
> steps to ensure it is a valid value. This failure mode doesn't cause us
> to prohibit inheritance of attributes.
Ridiculous. The docstring is an attribute of the function, not the class, which makes it very different from any other attribute. Consider this:
class A(object):
foo = SomeClass()
class B(A):
foo = SomeOtherUnrelatedClass()
Would you have B.foo "inherit" all the attributes of A.foo that it doesn't define itself? That's the analogous case to inheriting docstrings.
Carl Banks
More information about the Python-list
mailing list