Skip to content
Built-in Functions

locals()

Get the local names currently available in this part of the code.

locals()

locals() returns a dictionary of local variable names and their values.

It is mainly useful for inspecting code while learning or debugging.

Returns

A dictionary of local names and values.

Try it

Run it and change it
number = 7
print("number" in locals())

Related entries