> Let me try to summarize a few points that Alan has tried to > A variable is a name bound to a value in a namespace. > > A namespace is a dictionary in which Python can look up a name > (possibly) to obtain its value.
A namespace is *implemented* in Python as a dictionary. A namespace is a concept that applies in most computing languages and they all implement it differently. Many simply rely on the lexical context and the parser to control access. If you are using this for a class it's important that the students realise that the concept of namespace is distinct from the implementation details in Python. Its because the implementation details vary so much that I start the namespace topic in my tutor by saying: ------------------ "What's a namespace? I hear you ask. Well, it's kinda hard to explain. Not because they are especially complicated, but because every language does them differently. ..." ----------------- The concept is the same in every language but how they implement the concept is completely different in each one. Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor