Javatpoint Logo
Javatpoint Logo

Python locals() Function

The python locals() method updates and returns the dictionary of the current local symbol table.

A Symbol table is defined as a data structure which contains all the necessary information about the program. It includes variable names, methods, classes etc.

Signature

Parameters

It does not contain any parameters.

Return

It returns the dictionary of the current local symbol table.

Python locals() Function Example 1

The below example shows the working of locals() inside a local scope.

Output:

localsAbsent: {}
localsPresent: {'present': True}

Explanation: The above example updates and returns the dictionary of the current local symbol table.

Python locals() Function Example 2

The below example shows how to update locals() dictionary values.

Output:

True
True

Next TopicPython Functions




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA