364,111 Members | 2011 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

howto check is function capable of obtaining **kwargs?

dmitrey
P: n/a
dmitrey
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.
Jul 21 '08 #1
Share this Question
Share on Google+
1 Reply


Chris
P: n/a
Chris
On Jul 21, 1:20*pm, dmitrey <dmitrey.kros...@scipy.orgwrote:
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):
pass
>>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,
defaults).
'args' is a list of the argument names (it may contain nested
lists).
'varargs' and 'varkw' are the names of the * and ** arguments or
None.
'defaults' is an n-tuple of the default values of the last n
arguments.

Hope that helps.
Chris
Jul 21 '08 #2

Post your reply

Help answer this question



Didn't find the answer to your Python question?

You can also browse similar questions: Python