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 ask
It can also be used to get an instance of the class 'classname' from a string:
class C: def __init__(self, x): self.x = x print('Added new instance, x:', self.x) def call(str): obj = globals()[str](4) return obj c = call('C') print(c.x)