PyDocs

Nav

Python Runtime Services

locals

builtins

function
  • locals()
Return a dictionary containing the current scope's local variables.

NOTE: Whether or not updates to this dictionary will affect name
lookups in the local scope and vice-versa is *implementation
dependent* and not covered by any backwards compatibility
guarantees.
Changed in 3.12, 3.13
  • 3.12: The behaviour of locals() in a comprehension has been updated as described in PEP 709.
  • 3.13: As part of PEP 667, the semantics of mutating the mapping objects returned from this function are now defined. The behavior in optimized scopes is now as described above. Aside from being defined, the behaviour in other scopes remains unchanged from previous versions.
0 Examples
No examples for builtins/locals.
See Also
No see-alsos for builtins/locals
0 Notes
No notes for locals