Sunday, April 23, 2006

More on Namespaces

I'm in Manzanita on the Oregon Coast with family this First Day, having come over the low mountains on Hwy 26 after teaching Pythonic Mathematics for Saturday Academy at Portland State. All seven of my expected students eventually showed (one guy got seriously lost and came in with 30 minutes to go in a 2.5 hour class; a good opportunity to review).

In Python, a namespace is something you import. Complicated machinery lurks beneath the surface, perhaps triggered by common or familiar words, like Dog. If several Python modules define Dog, and you import from them, then watch out for name collisions! Which Dog class are we using? Dot notation to the rescue: ns1.Dog and ns2.Dog remain distinctly identifiable.

For further reading:
More Tech Talk @ Math Forum
Session Two @ Saturday Academy