Python namespace

A mapping from names to objects; each module, function call and class has its own, which is why the same name can mean different things in different places.

In more detail

Python keeps a function's local variables in a namespace that behaves like a dictionary, and locals() returns it. That is why format(**locals()) can fill a template from your variable names. Modules give their contents a namespace too, reached with a dot, as in math.pi.

Related terms

Taught in

References