Next / Previous / Contents / TCC Help System / NM Tech homepage

5.3. A namespace is like a dictionary

Back in Section 2.2, “The assignment statement”, we first encountered the idea of a namespace. When you start up Python in conversational mode, the variables and functions you define live in the “global namespace”.

We will see later on that Python has a number of different namespaces in addition to the global namespace. Keep in mind that namespaces are very similar to dictionaries:

We can even use the same picture for a dictionary that we use to illustrate a namespace. Here is a small dictionary and a picture of it:

d = { 'name': 'Ben Jones', 'front9': 33, 'back9': 31 }