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
Not really. Global variables Python really has are module-scoped variables.
# a.py print(globals()) import b b.tt()
# b.py def tt(): print(globals())
run python a.py, at least two output of globals()['__name__'] is different.
python a.py
globals()['__name__']
Code here in cpython on Github shows it.