>>> a = 4
>>> locals()['a']
4
>>> locals()['b'] = 'spam'
>>> b
'spam'
>>>
Declaring a variable is the same thing as accessing its name in the locals() dictionary (or the globals() dictionary if the variable is declared global).
But what if we do this:
class a:
b = 4
locals()['a.b'] = 'spam'
What will be the value of a.b?
But what if we do this:
class a:
b = 4
locals()['a.b'] = 'spam'
What will be the value of a.b?