Function Details: locals

Description


Returns a dictionary containing the current scope's local variables.


Extended Description


The locals() function returns a dictionary representing the current local symbol table. Free variables are returned by locals() when it is called in function blocks, but not in class blocks. Note that at the module level, locals() and globals() are the same dictionary.


Read More about locals from Python Documentation

Function Signature


locals() -> dict

Module: builtins

Parameters



Return


Returns a dictionary containing the local namespace.


Return Type


dict

Output

Explanation

This example shows how locals() returns a dictionary of local variables in a function.