Modules vs name spaces (Was: Global namespace)

Erann Gat gat at jpl.nasa.gov
Wed Oct 29 17:09:32 EST 2003


In article <pco7k2ndcpw.fsf_-_ at thoth.math.ntnu.no>, Harald Hanche-Olsen
<hanche at math.ntnu.no> wrote:

> + j-anthony at rcn.com (Jon S. Anthony):
> 
> | There's a difference between modules and name spaces, though modules
> | in many languages also serve as name spaces.
> 
> I have heard this one before, but have never quite understood the
> difference.  I am quite familiar with Lisp's packages and python's
> modules, and sure enough they are quite different, but I lack a clear
> conceptual distinction between modules and name spaces.  (I think it
> was even mentioned during an earlier discussion on c.l.lisp that it
> may be useful to have both available in the same language.)
> 
> So, can anyone either explain the difference, or point to a resource
> (preferably on the web) that explains it?

Packages map strings onto symbols (identifier objects).

Modules map symbols/identifiers onto values.

Packages work at read/parse time.

Modules work at compile time or run time depending on the module system.

Common Lisp has a package system but no module system (but it's possible
to add one -- see e.g. http://www.flownet.com/gat/locales.pdf).

Python has a module system that works at run-time, but no package system.

Does that help?

E.




More information about the Python-list mailing list