locals()
Built-in FunctionPython 2.0+Advanced
Returns a dictionary of the current local symbol table
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
def example(): a = 1 b = 2 print(locals()) example()
locals() is a built-in function that returns a dictionary of the current local symbol table.
Try in PlaygroundTags
builtinfunctioncorescopeintrospection
Related Items
globals()
Built-in Function
Returns a dictionary of the current global 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