howto check is function capable of obtaining **kwargs?

Chris cwitts at
Mon Jul 21 13:44:44 CEST 2008

On Jul 21, 1:20 pm, dmitrey <dmitrey.kros... at> wrote:
> hi all,
> howto check is function capable of obtaining **kwargs?
> i.e. I have some funcs like
> def myfunc(a,b,c,...):...
> some like
> def myfunc(a,b,c,...,*args):...
> some like
> def myfunc(a,b,c,...,*args, **kwargs):...
> some like
> def myfunc(a,b,c,...,zz=zz0):...
> So I need to know is the given function capable of handling zz
> parameter, for example the call
> myfunc(a,b,c,...,zz=4,...)
> Thank you in advance, D.

>>> def f(a, b=1, c={}, *args, **kwargs):

>>> inspect.getargspec(f)
(['a', 'b', 'c'], 'args', 'kwargs', (1, {}))

>>> print inspect.getargspec.__doc__
Get the names and default values of a function's arguments.

    A tuple of four things is returned: (args, varargs, varkw,
    'args' is a list of the argument names (it may contain nested
    'varargs' and 'varkw' are the names of the * and ** arguments or
    'defaults' is an n-tuple of the default values of the last n

Hope that helps.

More information about the Python-list mailing list