docstring reference to another docstring

bdb112 boyd.blackwell at gmail.com
Tue Mar 10 00:17:09 CET 2009


"""" Thanks for the quick reply - I expanded it to a working program,
it seems to do the job and works in my actual code (always good).  As
you said, it assumes the called function's class is already defined.
Is there a way around this? (The module was originally ordered
"top-down").
""""

class Cluster():
    """Cluster docs...
    """

    def plot():
        """Cluster.plot docs..
        """


class ClusterSet():
    """ClusterSet docs...
    """
    __doc__  += "extra" + Cluster.__doc__

    def plot():
        """ClusterSet.plot docs..
        """
        __doc__  += "this is not what we want, it \
                     only happens at runtime, and refers to a local
variable"
        print("ClusterSet.plot body")

    plot.__doc__  += "extra" + Cluster.plot.__doc__


cs=ClusterSet()

print(cs.__doc__)
print(cs.plot.__doc__)
On Mar 10, 7:30 am, Chris Rebert <c... at rebertia.com> wrote:
> On Mon, Mar 9, 2009 at 3:23 PM, bdb112 <boyd.blackw... at gmail.com> wrote:
> > A function of the class ClusterSet uses a similar function of the
> > class Cluster to do most of its work.  Its docstring could have so
> > much in common with that in Cluster that it could be just a line or
> > two in addition to that of Cluster.
>
> > Is there a way for the ClusterSet docstring to tack the Cluster
> > docstring onto itself, rather than simply saying "See docstring for
> > Cluster"?
>
> #assume Cluster already defined by this point
> class ClusterSet(object):
>     __doc__ = Cluster.__doc__
>     #rest of class body
>
> Cheers,
> Chris
>
> --
> I have a blog:http://blog.rebertia.com




More information about the Python-list mailing list