feedback on function introspection in argparse
Yuv
ubershmekel at gmail.com
Sat Nov 7 18:44:33 EST 2009
On Nov 8, 1:33 am, Carl Banks <pavlovevide... at gmail.com> wrote:
> Is the docstring expected to be formatted according to some
> convention?
Yes it does, we parse the docstring as explained in argparse.py:
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
parameter
name immediately followed by any amount of whitespace, hyphens or
colons.
The rest of the line following the colon/hyphen/whitespace is the
help.
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
strings
"""
We tried to comply to PEP 257 and we're open to suggestions on this.
--yuv
More information about the Python-list
mailing list