Vote count:
0
If I do this:
newvar = raw_input()
globals()[newvar] = 4
It is clear that the resulting variable is created at runtime, simply because it's the only possibility. However, if I do this:
globals()['y']=3
It seems that y
is also created at runtime. Why is it the case? Where does the dynamic behavior come from?
PS: I am aware that this is a bad practice, I just want to understand.
asked 2 mins ago
Dynamic creation of variables and modification of globals()
Aucun commentaire:
Enregistrer un commentaire