473,320 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

howto check is function capable of obtaining **kwargs?

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
1 1577
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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Vedran Furac | last post by:
How can I call a function every time a specified number of milliseconds elapses? Javascript has setInterval() function and I need something like that. Currently I use this: def function(): t =...
3
by: James Stroud | last post by:
Hello All, I did this: py> class bob(object): .... def __init__(self,**kwargs): .... for fname,func in kwargs.items(): .... setattr(self, fname, lambda *args : func(*args)) .......
11
by: Riccardo Galli | last post by:
Hi all. It's easier if I show an example first. Say I have class A(object): def speak(self): print 'A!' class B(object): def speak(self): print 'B!'
38
by: Lasse Vågsæther Karlsen | last post by:
After working through a fair number of the challenges at www.mathschallenge.net, I noticed that some long-running functions can be helped *a lot* by caching their function results and retrieving...
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
14
by: emailscotta | last post by:
Some of the object properties in the Dojo Toolkit are set to objects but they are using syntax like this: object.property = new function() { this.property = someValue; this.property =...
6
by: rh0dium | last post by:
Hi Experts!! I am trying to get the following little snippet to push my data to the function func(). What I would expect to happen is it to print out the contents of a and loglevel. But it's...
10
by: rh0dium | last post by:
Hi all, Below is a basic threading program. The basic I idea is that I have a function which needs to be run using a queue of data. Early on I specified my function needed to only accept basic...
13
by: dmitrey | last post by:
I need something like this: def func1(*args, **kwargs): if some_cond: return func2(*args, **kwargs) else: return func3(some_other_args, **kwargs) Thank you in advance, D.
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.