ScanSkill

locals

This locals() function returns a dictionary representing the current local symbol table.

Syntax

locals()

Note: The contents of this dictionary should not be modified; changes may not affect the values of local and free variables used by the interpreter.

Examples

>>> locals()
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, 
'__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>}

Here, a Local Symbol table stores all the information related to the program's local scope, which is accessed with locals() method.

>>> a = 25
>>> locals()
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, 
'__builtins__': <module 'builtins' (built-in)>, 'a': 25}