What if positional argument is one of keyword arguments in Python
Short answer: an error.
Here is an example.
Define myprint()
:
def myprint(first_name, **kwargs):
print(f"{kwargs}")
print(f"first_name {first_name}")
myprint(first_name="John", **{"last_name" : "Smith"})
Output:
{'last_name': 'Smith'}
first_name John
myprint(first_name="John", **{"first_name": "Joe", "last_name" : "Smith"})
Output:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 myprint(first_name="John", **{"first_name": "Joe", "last_name" : "Smith"})
TypeError: __main__.myprint() got multiple values for keyword argument 'first_name'