Given a function that accepts "**kwargs", e.g.,
def f(**kwargs):
print(kwargs)
how can I pass a key-value pair if the key contains a dot/period (.)?
The straightforward way results in a syntax error:
In [46]: f(a.b=1)
Cell In[46], line 1
f(a.b=1)
^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
Python functions only accepts valid python names (letters, underscore, and digits except for the first character), a dot is not allowed.
If you want to have a string
a.bas parameter, then you must use a dictionaryYou can combine this with other parameters: