introspecting builtin functions/methods

Fredrik Lundh fredrik at pythonware.com
Tue Dec 16 17:03:05 CET 2003


Gonçalo Rodrigues wrote:

> Does anyone know if and how I can, from within Python, read the
> signatures of builtin methods/functions?

For methods/functions written in C, the signature is defined by a
string passed to an internal C function (ParseTuple).  And functions
don't even have to use that function to process their arguments;
they can pull values right out of the argument tuple (or they can
use ParseTuple more than once, in order to support multiple calling
conventions).

I'd say your only hope is the doc string:

>>> inspect.getdoc(list.append)
'L.append(object) -- append object to end'

</F>








More information about the Python-list mailing list