Reason for globals() in Python?
问题 What is the reason of having globals() function in Python? It only returns dictionary of global variables, which are already global, so they can be used anywhere... I'm asking only out of curiosity, trying to learn python. def F(): global x x = 1 def G(): print(globals()["x"]) #will return value of global 'x', which is 1 def H(): print(x) #will also return value of global 'x', which, also, is 1 F() G() H() I can't really see the point here? Only time I would need it, was if I had local and