ScanSkill

globals

This globals() function returns a dictionary representing the current global symbol table.

Syntax

globals()

Note: Returned value is always the dictionary of the current module (inside a function or method, this is the module where it is defined, not the module from which it is called).

Examples

>>> globals()
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, 
'__builtins__': <module 'builtins' (built-in)>}

Here, a Global Symbol table stores all the information related to the program's global scope, which is accessed with globals() method.

>>> a = 25
>>> globals()['a'] = 23
>>> a
23

Here, the value of variable a is changed to 23 using the globals() method with dictionary key [’a’].