introspecting builtin functions/methods

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Tue Dec 16 11:03:36 EST 2003


On Tue, 2003-12-16 at 15:56, =?UNKNOWN?Q?Gon=E7alo?= Rodrigues wrote:
> 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


You mean something like:

>>> list.append.__doc__
'L.append(object) -- append object to end'
>>> list.count.__doc__
'L.count(value) -> integer -- return number of occurrences of value'





-- 
Martin Franklin <mfranklin1 at gatwick.westerngeco.slb.com>






More information about the Python-list mailing list