introspecting builtin functions/methods

Gonçalo Rodrigues op73418 at mail.telepac.pt
Tue Dec 16 10:56:45 EST 2003


Hi,

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

The following fails:

>>> import inspect
>>> inspect.getargspec(list.append)
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python23\lib\inspect.py", line 655, in getargspec
    raise TypeError('arg is not a Python function')
TypeError: arg is not a Python function
>>> inspect.getargspec(list.append.__call__)
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python23\lib\inspect.py", line 655, in getargspec
    raise TypeError('arg is not a Python function')
TypeError: arg is not a Python function

Also:

>>> for elem in dir(list.append):
... 	print elem
... 	
__call__
__class__
__delattr__
__doc__
__get__
__getattribute__
__hash__
__init__
__name__
__new__
__objclass__
__reduce__
__reduce_ex__
__repr__
__setattr__
__str__

gives no clue.

TIA, with my best regards,
G. Rodrigues




More information about the Python-list mailing list