I wrote this code and received an unexpected output than I thought.
def egg():
print(a)
egg() # NameError: name 'a' is not defined **As excepted**
egg.a = 50
egg() # NameError: name 'a' is not defined **Not as excepted**
My hope was that after setting agg.a = 50 the next time I would call agg() a variable will be defined.
Can someone please explain what am I missing?
why a is not added to the function scope dynamically
p.s. when I used dir(egg) I could see a was add the the function dict