docstrings

Mark Jackson mjackson at wc.eso.mc.xerox.com
Thu Apr 20 12:22:49 EDT 2000


Ben Wolfson <rumjuggler at home.com> writes:
> is there a way to use %c and %s within a docstring, or to add strings
> together in a docstring, so that if some strings are used in all
> docstrings, but might be changed, I can simply change one or two
> variables?

This might do what you want, although it's ugly (in the sense that it
serves the code-documentation - as opposed to user-documentation -
function less well):

    cat > spam.py
    """I am a docstring"""
    
    sharedoc = """ and I am a widely-reused docstring clause"""
    
    __doc__ = __doc__ + sharedoc
    
    del sharedoc
    ^D
    yngvi> python
    Python 1.5.2 (#7, May  6 1999, 14:39:45)  [GCC 2.8.1] on sunos5
    Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
    >>> import spam
    >>> print spam.__doc__
    I am a docstring and I am a widely-reused docstring clause
    >>> 

-- 
Mark Jackson - http://www.alumni.caltech.edu/~mjackson
	An advertiser will happily make you feel bad about
	yourself if that will make you buy, say, a Bic pen.
				- George Meyer





More information about the Python-list mailing list