calling the function police

EP EP at zomething.com
Mon Dec 22 11:15:05 EST 2003


> > >>> result=function1('Jim Beam', 'Poker',first=parameter,end='noodles')
> >
> > and got this error:
> >
> > >TypeError: function1() got multiple values for keyword argument 'first'
> >
>
>    'Jim Beam' is passed as an argument for "first".  'Poker' as an argument
>for "end".  Then, parameter is passed as an argument for "first", and
>'noodles' as an argument for "end".  No arguments are passed for the
>*argument (I forget what it was called in your example).
>
>   In general, the first argument matches up with the first parameter, the
>second with the second, and so forth.


This seems to be what is happening but does not seem compatible with the 
rules (or maybe my expectations):

1) keyword arguments must appear after non-keyword arguments in the call.
2) in the function header, *arguments must come after normal arguments and 
defaults

If I am concluding correctly, this means that keywords cannot be used in a 
function call for a function header like this

def function(value1=x, value2=y, *arguments)
Is that right?  the two rules mean that keywords will out of "position", 
source to target; but why would keywords have to be accessed by position, 
aren't they akin to a dictionary?

Not a terrible limitation, was just not expected.

Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20031222/5a2f0451/attachment.html>


More information about the Python-list mailing list