Python globals() function

Instance

Display the global symbol table:

x = globals()
print(x)

Run Instance

Definition and Usage

The globals() function returns the global symbol table as a dictionary.

The symbol table contains necessary information about the current program.

Syntax

globals()

Parameter Value

No Parameters

More Examples

Instance

Get the filename of the current program:

x = globals()
print(x["__file__"])

Run Instance