Any way to get information from fun objects about their parameters?
amy-g-art at cox.net
Thu Mar 25 02:29:36 CET 2004
"Gonçalo Rodrigues" <op73418 at mail.telepac.pt> wrote in message
news:alc460hokb7sj39m06022m4ao5gp9cdbcu at 4ax.com...
> On Thu, 25 Mar 2004 00:49:57 GMT, Kenneth McDonald
> <kmmcdonald at wisc.edu> wrote:
> >For autodocumentation purposes, I'd like to be able to load a module
> >and then find out the following information about functions and
> >methods defined within it:
> >1) Parameter names and order
> >2) Default value, if any, associated with each parameter
> >3) If the *param or **param conventions are used in the
> >parameter list.
I think the inspect.getsource(modname) might be even better. It will
preserve order and provide these other requests as well.
> >Reading documentation about function objects, the only
> >relevant information I can extract is a tuple representing
> >default param values, which is not useful to me.
> >I know I could probably do this by parsing the module, but
> >I would strongly prefer a simpler way. I'd have thought that,
> >like docstrings and many other properties, the parameter info
> >would also be stored with function objects.
> Check out the inspect module. In particular the getargspec function.
> With my best regards,
> G. Rodrigues
More information about the Python-list