call f(a, *b) with f(*a, **b) ?
inhahe
inhahe at gmail.com
Fri May 23 15:35:27 EDT 2008
"
I wish this worked:
>>> def main(a,b,*argv): pass
>>> options['argv'] = argv
>>> main(**options)
TypeError: main() got an unexpected keyword argument 'argv'
"
-----
I was thinking about that exact same thing actually. Except that I was
thinking you might want it like this, otherwise it could be ambiguous:
>>> def main(a,b,*argv): pass
>>> options['*argv'] = argv
>>> main(**options)
Weird I know, to put the * operator inside the string. I suppose the
necessity of doing that just shows why it wasn't implemented in the first
place. But still, it would be neat...
Also, of course, you could then do
main(*argv=[2,3])
or rather
main(*argv=[3,4],a=1,b=2) #in random order
More information about the Python-list
mailing list