[Tutor] dynamic argument lists
eShopping
etrade.griffiths at dsl.pipex.com
Fri Aug 29 15:49:33 CEST 2008
Hi
I have a GUI program that extracts some information from the user as
strings, and I then want to use the strings to form an argument list
to another function. Hopefully the following code gives some flavour:
def myfunc(**kwargs):
while kwargs:
name, value = kwargs.popitem()
print name, value
myfunc(a=1, b=2, c=3, d=4)
arg_str = "a=1, b=2, c=3, d=4"
myfunc(arg_str)
ARG_STR will be built up from the data extracted from the GUI. I get
this error
TypeError: myfunc() takes exactly 0 arguments (1 given)
I understand that ARG_STR is a string and that MYFUNC is expecting
something else ,,, but not sure what it is. I have tried various
dictionary configurations such as
arg1 = ["a","b","c","d"]
arg2 = [1,2,3,4]
arg3 = dict(zip(arg1,arg2))
myfunc(arg3)
but still get the same error message. All suggestions welcome!
Thanks in advance
Alun Griffiths
More information about the Tutor
mailing list