THE WORLD'S LARGEST WEB DEVELOPER SITE

Python globals() Function

❮ Built-in Functions


Example

Dispaly the global symbol table:

x = globals()
print(x)
Run example »

Definition and Usage

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

A symbol table contains necessary information about the current program


Syntax

globals()

Parameter Values

No parameters


More Examples

Example

Get the filename of the current program:

x = globals()
print(x["__file__"])
Run example »

❮ Built-in Functions