"TypeError: got multiple values ββfor argument" after using functools.partial ()
Consider the following piece of code that uses functools.partial()
:
import functools
def add(a, b):
return a + b
add_10 = functools.partial(add, a=10)
add_10(4)
When I ran it I got the following error:
Traceback (most recent call last): File "test.py", line 7, in <module> add_10(4) TypeError: add() got multiple values for argument 'a'
When I change the keyword argument to a positional argument on the penultimate line, it passes:
add_10 = functools.partial(add, 10)
Why doesn't it pass in the first case? I am using Python 3.4.
+3
source to share