Python – Find Current Local Symbol Table Dictionary – locals() Function with Examples

locals() function is used to find the the dictionary of the current local symbol table in Python for the given input.

locals() function is a part of Python Built-in Functions.

Syntax of locals() Function

The syntax of locals() function in Python is:

locals()

 

Parameters of locals() Function in Python

x – Where x is any valid . This parameter is required.

 

Compatibility

locals() function is available and compatible with both Python 2.x and 3.x.

 

Return Value of locals() Function in Python

locals() function returns the dictionary of the current local symbol table for the given input.

 

Python locals() Function Example 1

Example CODE

Output:

 

Python locals() Function Example 2

Example CODE

Output: