When handling connection string attributes, I noticed a curious behavior in Python's argument unpacking. Passing in an argument that has spaces in the name works.
def f(**kwargs):
print(kwargs)
f(spaced keyword=3) # Syntax error
f(**{'spaced keyword': 3}) # Fine
When I first heard about argument unpacking, I naturally assumed that the above calls would be identical. So in the above example even the unpacking would lead to an error. Not a syntax one, but perhaps something to do with illegal arguments.
A string is enforced.
f(**{2: 3}) # Type error
But an empty string works too.
f(**{'': 3, '\a': 4, '\n': 5}) # Fine
Obviously one cannot name the arguments in the function definition, but I'm still wondering what exactly is going on. The calls are not identical. Is there some documentation on how they differ or how the unpacked arguments are processed compared to plain keyword arguments? So, if the syntax was allowed in definitions, variable names and calling the function, does everything after that already work for spaced argument names?