[Python-Dev] Should inspect.getargspec take any callable?

Nick Coghlan ncoghlan at gmail.com
Sat Jan 16 22:32:55 EST 2016


On 17 January 2016 at 03:23, Andrew Barnert via Python-Dev
<python-dev at python.org> wrote:
> On Jan 16, 2016, at 08:05, Aviv Cohn via Python-Dev <python-dev at python.org>
> wrote:
>
> The `getargspec` function in the `inspect` module enforces the input
> parameter to be either a method or a function.
>
>
> The `getargspec` already works with classes, callable objects, and some
> builtins.
>
> It's also deprecated, in part because its API can't handle various features
> (like keyword-only arguments). There is an extended version that can handle
> some of those features, but as of 3.5 that one is deprecated as well.
>
> The `signature` function is much easier to use, as well as being more
> powerful.

As Andrew states here, the limitations of getargspec() and
getfullargspec() are why they were deprecated in favour of
inspect.signature() in Python 3.3:
https://docs.python.org/3/library/inspect.html#introspecting-callables-with-the-signature-object

The funcsigs project provides a backport of much of that functionality
to earlier Python versions: https://pypi.python.org/pypi/funcsigs

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list