[Python-Dev] inspect.getargspec()
Patrick K. O'Brien
pobrien@orbtech.com
Thu, 7 Nov 2002 10:15:43 -0600
On Thursday 07 November 2002 09:19 am, Guido van Rossum wrote:
> I'm with Ping -- the signature returned should only report arguments
> you need to supply. So in the above, the signature for X.append would
> be (self, item) but the signature for X().append would be (item).
And that's what my current code does. So I'll work up a patch in the next
day or two and make this functionality part of inspect.
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?
--
Patrick K. O'Brien
Orbtech http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------