Next / Previous / Contents / Shipman's homepage

21.22. vars(): Local variables

This function returns a dictionary that represents a symbol table: its keys are variable names, and each key's corresponding value is its bound value. The official documentation warns you not to change anything in this dictionary, or Bad Things Will Happen.

There are two forms of call:


Returns the local symbol table.


Returns the symbol table of a namespace ns, where a namespace can be a module, an instance, or a class.

Compare the similar functions Section 21.5, “dir(): Display a namespace's names”, Section 21.14, “locals(): Dictionary of local name bindings”, and Section 21.9, “globals(): Dictionary of global name bindings”.