calling the function police

E

EP

Hi,

"I'm new and confused"
"Hello 'New and Confused'"

TypeError: function1() got multiple values for keyword argument 'first'
together, extra=' ',' '
for each in extras:
try:
extra+=each
except TypeError:
extra+=`each`
together=first+extra+end
return together

TypeError: function1() got multiple values for keyword argument 'first'

What rule have I violated?
This seems to be associated with the assignment of a variable to a keyword
argument in the function call. Is this illegal?
If so, why is this a crime? The logic isn't popping out at me...

Thanks....


Eric

[I resorted to relying on order rather than keywords in the call to make it
work]
 
V

vincent wehren

| Hi,
|
| "I'm new and confused"
| "Hello 'New and Confused'"
|
| TypeError: function1() got multiple values for keyword argument 'first'
|
| >>> def function1 (first='Jimminy Cricket', end='suffix', *extras):
| together, extra=' ',' '
| for each in extras:
| try:
| extra+=each
| except TypeError:
| extra+=`each`
| together=first+extra+end
| return together
|
| >>> parameter='something'
|
| >>> result=function1(first=parameter, end='noodles','Jim Beam', 'Poker')
|
| TypeError: function1() got multiple values for keyword argument 'first'

I would expect you to get something like "SyntaxError: non-keyword arg after
keyword arg" (at least in 2.3.x).

Vincent Wehren


|
| What rule have I violated?


I would expect you to get something like "SyntaxError: non-keyword arg after
keyword arg" (at least in 2.3.x).

Vincent Wehren




| This seems to be associated with the assignment of a variable to a keyword
| argument in the function call. Is this illegal?
| If so, why is this a crime? The logic isn't popping out at me...
|
| Thanks....
|
|
| Eric
|
| [I resorted to relying on order rather than keywords in the call to make
it
| work]
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top