I have a seemingly easy question which I can't find an answer to. With a simple function such as the following:
def test_kwargs_1(a,**kwargs):
print a
print b
I was thinking that, if I passed:
kwargs = {'a':1,'b':2}
test_kwargs_1(**kwargs)
it would print:
1
2
as it would unpack "kwargs" and both a variable "a" and "b" would be available. Instead i get:
1
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
.
.
----> 3 print b
NameError: global name 'b' is not defined
I understand that "b" is a variable which may or may not exist, but I thought that the unpacking of kwargs would make the variable "b" available if explicitly defined in kwargs. What am I not getting? Thanks, s