On this page
  1. locals
  2. Import & Availability
  3. Overview & Signature
  4. Usage
  5. Gotchas
  6. REPL Inspect

locals

Prev: list | Up: __builtins__ | Next: map
Rel: breakpoint, compile, eval, exec, globals
Ref: docs.python.org — locals
Tags: #public #python3 #builtins


Import & Availability

# Built-in (available globally without import)
from builtins import locals

Overview & Signature

locals()

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

Usage

def compute():
    a, b = 3, 4
    return locals()

assert compute() == {"a": 3, "b": 4}

Gotchas

REPL Inspect

help(locals)

Linked from

Related notes