docstrings

Ben Wolfson rumjuggler at home.com
Fri Apr 21 14:14:36 EDT 2000


On 20 Apr 2000 16:22:49 GMT, mjackson at wc.eso.mc.xerox.com (Mark
Jackson) wrote:

>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
>    >>> 

This approach doesn't work for function docstrings, unless I tried it
wrong.

-- 
Barnabas T. Rumjuggler

He still loves life,
But O O O O how he wishes
The good Lord would take him.
 -- W. H. Auden



More information about the Python-list mailing list