feedback on function introspection in argparse

Yuv ubershmekel at
Sun Nov 8 00:44:33 CET 2009

On Nov 8, 1:33 am, Carl Banks <pavlovevide... at> wrote:
> Is the docstring expected to be formatted according to some
> convention?

Yes it does, we parse the docstring as explained in
def _parse_docstring(function):
    """Parses a function's docstring for a description of the function
and for
    help on the individual parameters.

    The parsing algorithm currently looks for lines that start with a
    name immediately followed by any amount of whitespace, hyphens or
    The rest of the line following the colon/hyphen/whitespace is the

    Keyword Arguments:
        function - the function whose docstring is parsed.

    Returns a (description, help_dict) tuple:
        description - all text before the first documented parameter
        help_dict - a dictionary mapping parameter names to their help

We tried to comply to PEP 257 and we're open to suggestions on this.


More information about the Python-list mailing list