0

parameter name which act a varible &which isn't string then why there is conflict between parameter name & 'name' in block ?

Finally, consider this function definition which has a potential collision between the positional argument name and **kwds which has name as a key: def foo(name, **kwds): return 'name' in kwds There is no possible call that will make it return True as the keyword 'name' will always to bind to the first parameter. For example: >>> foo(1, **{'name': 2}) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: foo() got multiple values for argument 'name' >>>

3rd Jun 2021, 8:57 AM
lisa
3 Respostas
+ 1
# this one will return True: def foo(**kwds): return 'name' in kwds print(foo(**{'name': 2}) )
3rd Jun 2021, 9:17 AM
visph
visph - avatar
0
+*********22
3rd Jun 2021, 2:10 PM
Thiên Khắc
Thiên Khắc - avatar
0
Thiên Khắc what's this ? "+*********22"
3rd Jun 2021, 2:37 PM
lisa