Python globals() function doesn’t have any arguments. The globals() function returns a dictionary of a current module (inside the function or method, lt is the  module where it is defined, not a module from which it is called).

Python globals()

Python globals() is an inbuilt function that returns the  dictionary of the current global symbol table. A symbol table is the data structure that contains all the necessary information about the program. These include variable names,  methods,  classes, etc.

Python maintains program information in the symbol tables. There are two types of symbol tables.

  1. Local Symbol Table: It stores information related to the local scope of the program. We can get these details using the locals() function. The local scope could be within the function, within the class, etc.
  2. Global Symbol Table: It stores information related to the global scope of the program. We can get these details using the globals() function. The global scope contains all the functions, variables that are not associated with any class or function.

#python #python globals

Python globals: How to Use globals() Method in Python
2.65 GEEK