**argv can't work
rzed
rzantow at gmail.com
Fri Jan 19 22:33:26 EST 2007
"Jm lists" <practicalperl at gmail.com> wrote in
news:mailman.2928.1169263231.32031.python-list at python.org:
> hello members,
>
> See my script piece below:
>
> def testB(shift,**argv):
> print "first argument is %s" %shift
> print "all other arguments are:",argv
>
> testB('mails','Jen','Jen at att.com','Joe','Joe at aol.com')
>
> It can't work at all.please help tell me the reasons.thanks.
>
You have too many asterisks before argv. Use just one, like this:
def testB(shift,*argv):
print "first argument is %s" %shift
print "all other arguments are:",argv
testB('mails','Jen','Jen at att.com','Joe','Joe at aol.com')
Two asterisks signifies keyword arguments, like this:
def f(**c):
for k,v in c.items():
print k,v
f(a=1,b=2)
More information about the Python-list
mailing list