Code blocks that create a namespace

Some Python code blocks set up a special area to store the names they know about. (Names are labels for areas of computer storage that hold particular values or other objects.) These areas are called namespaces.

Each namespace is self-contained, so names from different parts of a program don't bump into each other. This feature lets Python programmers create modular code that can be extended in many different directions without having to worry about whether their new code uses the same names as code in other blocks, modules, or programs.

Several kinds of code blocks create namespaces. Here is a brief introduction to some of them.

Was this article helpful?

0 0

Post a comment