def myfunc(a,b=2):
print("Called with", a, b)
return
p1 = functools.partial(myfunc, b=4)
p1("foobar", 4)
Why do I get a syntax error when I run that last line? It works if i do: myfunc("foobar", 4)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
‘partial’ already sets ‘b’ to 4; if you want another value you should explicitely set parameter ‘b’: