I understand the function arguments must have the following ordering hierarchy:
*args
**kwargs
I'm getting this error:
SyntaxError: keyword can't be an expression
in the below:
def dfDiff(old, new, **kwargs):
# default dict of optional function arguments
d = {'city': 'Austin',
'capital': True,
'indx' : 5}
# if optional args are provided
if kwargs is not None:
# find the common keys
k_passed = kwargs.keys() & d.keys()
# change the default value
for k in k_passed:
d[k] = kwargs[k]
test_ = dfDiff(1, 2, 'city' = 'Albany')
did I pass **kwargs
incorrectly or there is some other issue?
city='Albany'
, don't wrap city
in quotation marks.