[SciPy-Dev] Reusing docstrings of the parent class in overridden methods of a subclass

Warren Weckesser warren.weckesser at gmail.com
Thu May 23 16:56:41 EDT 2013


In scipy.stats.distributions, some of the distribution classes (subclasses
of rv_continuous) override, say, the `fit` method.  See, for example,
gamma_gen or beta_gen.  Is there a standard way for the `fit` method of the
subclass to use the docstring of the `fit` method in the parent class?  In
python 2.7, this monkey patching seems to work:

beta_gen.fit.__func__.__doc__ = rv_continuous.fit.__doc__

(This is what I did in https://github.com/scipy/scipy/pull/2519)

In python 3.3, however, beta_gen.fit does not have the __func__ attribute.

Is there a recommended way to do this?  The docstring is rather long, and
I'd rather not repeat it in the subclass.

Warren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20130523/4bab6495/attachment.html>


More information about the SciPy-Dev mailing list