Python globals() Function

Returns a dictionary of the current global symbol table. In this example, we are filtering the globals to exclude Python defined globals, which always are preceded with '__'. This is often more useful, so you can see only the variables that you've created that are global.

Syntax

Python
globals()

Example

Python
aGlobal = 1
anotherGlobal = 'Hello World'

myGlobals = list(filter(lambda s: not(s.startswith('__')), globals()))
print(myGlobals)

Output

['aGlobal', 'anotherGlobal']