12.12. Idiom Locals

Update and return 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 [1].


The contents of this dictionary should not be modified; changes may not affect the values of local and free variables used by the interpreter.

12.12.1. References