globals()
Built-in FunctionPython 2.0+Advanced
Returns a dictionary of the current global symbol table
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
x = 42 g = globals() print("x" in g) print(g["x"])
globals() is a built-in function that returns a dictionary of the current global symbol table.
Try in PlaygroundTags
builtinfunctioncorescopeintrospection
Related Items
locals()
Built-in Function
Returns a dictionary of the current local symbol table
vars()
Built-in Function
Returns the __dict__ attribute of an object
dir()
Built-in Function
Lists the names (attributes and methods) of an object or current scope
eval()
Built-in Function
Evaluates a string as a Python expression and returns the result
exec()
Built-in Function
Executes a string or code object as Python statements