P
Paddy
Hi, I just found the following oddity where for function fsf1 I am forced to use a named parameter for correct evaluation and was wondering why it doesn't work, yet the example from the docs of wrapping int to create basetwo doesn't need this?
The example:
File "<pyshell#24>", line 1, in <module>
fsf1(s)
TypeError: fs() got multiple values for keyword argument 'f'
Would someone help?
- Thanks in advance, Paddy.
The example:
Traceback (most recent call last):from functools import partial
basetwo = partial(int, base=2)
basetwo('10010') 18
def fs(f, s): return [f(value) for value in s]
def f1(value): return value * 2
s = [0, 1, 2, 3]
fs(f1, s) [0, 2, 4, 6]
fsf1 = partial(fs, f=f1)
fsf1(s)
File "<pyshell#24>", line 1, in <module>
fsf1(s)
TypeError: fs() got multiple values for keyword argument 'f'
# BUT
fsf1(s=s) [0, 2, 4, 6]
Would someone help?
- Thanks in advance, Paddy.