On Tue, Nov 8, 2016 at 8:58 AM, 'Martin R' via sage-devel <sage-devel@googlegroups.com> wrote: > Thanks for these hints! I'm afraid that I still have to go with Jeroen's > solution, because I'd like to have different descriptions of the class, only > what's displayed as "Init docstring" should be kept. > > It's actually strange that non-present docstrings of methods which are > overwritten are not taken from the parent class.
It is an annoyance. I think I asked Python-dev about this once before, and there was a reason for it, but I don't remember what the explanation was. I didn't mean to keep tossing out links to stuff in Astropy, but there is a workaround for this: http://docs.astropy.org/en/stable/api/astropy.utils.misc.InheritDocstrings.html If you use the InheritDocstrings metaclass then your class will do just this. Just be aware that if you use a metaclass you have to be aware of the downsides to that (namely metaclass conflicts in inheritance). > Am Montag, 7. November 2016 16:04:07 UTC+1 schrieb Travis Scrimshaw: >> >> >> >> On Monday, November 7, 2016 at 7:26:57 AM UTC-6, Jeroen Demeyer wrote: >>> >>> On 2016-11-07 14:13, 'Martin R' via sage-devel wrote: >>> > I would like that these subclasses inherit the docstring of >>> > GrowthDiagram.__init__ (and a few other methods), but I do not know how >>> > to achieve this. >>> >>> sage: class B(A): >>> ....: def __init__(self): >>> ....: pass >>> ....: __init__.__doc__ = A.__init__.__doc__ >>> >> >> IIRC, another option would be to put it in the class-level doc, which is >> automatically passed down provided the subclass doesn't do its own >> class-level doc. >> > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.