• locals() - Dictionary of local variables
• globals() - Dictionary of global variables
def test_fun():
a=2
print(locals())
print(globals())
test_fun()
Output :
{
'a': 2}
{
'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x7f4759f254c0>, '__spec__': None, '__annotations__': {
}, '__builtins__': <module 'builtins' (built-in)>,....,'test_fun': <function test_fun at 0x7f4759ee21f0>}