[Python-ideas] inheriting docstrings and mutable docstings for classes
Dj Gilcrease
digitalxero at gmail.com
Fri Jun 10 15:29:18 CEST 2011
On Fri, Jun 10, 2011 at 3:28 AM, Arnaud Delobelle <arnodel at gmail.com> wrote:
> Given that Python supports multiple inheritance, which parent class's
> __doc__ would the __basedoc__ contain? Also, what would the
> __basedoc__ contain if the parent's __doc__ is empty but not its
> __basedoc__?
You would not need a __basedoc__ magic attribute, you can just do
class C(object): pass
docs = [c.__doc__ for c in C.__mro__]
and you get the docs for all bases in the proper mro order
Though I guess __basedocs__ mapping to [c.__doc__ for c in C.__mro__
if c != C] could be handy
More information about the Python-ideas
mailing list