[Python-Dev] inspect.getargspec()

holger krekel pyth@devel.trillke.net
Thu, 7 Nov 2002 17:43:24 +0100

Patrick K. O'Brien wrote:
> Any opinions on how to handle builtins? Should getargspec() return empty 
> values or raise an error? The current version raises TypeError on anything 
> that fails isinstance(object, types.FunctionType). The new version will 
> support functions, bound methods, unbound methods, classes (which returns 
> the contructor's arguments), and objects with a __call__() method (and will 
> drop self as appropriate for all permutations of the preceding).
> It doesn't seem right to me to raise an error for a builtin, especially if 
> there will come a day when we *can* introspect the arguments for builtins. 
> I'd rather return empty values and just document the fact that we don't 
> have a way to return the argspec on builtins yet. Yay, nay, other?
> Neither solution is entirely satisfactory. Is there no trick that could be 
> employed to expose the argspec for builtins?

For a documentation browser i used the technique to parse the 
docstring of the builtins (which contains the signature).  
It's difficult to get exact information out of them, though. 
The problem is that some docstrings are 'incorrect' or
slightly non-standard.