Modules vs name spaces (Was: Global namespace)

Henrik Motakef usenet-reply at henrik-motakef.de
Thu Oct 30 17:01:37 EST 2003


Henrik Motakef <usenet-reply at henrik-motakef.de> writes:

> Harald Hanche-Olsen <hanche at math.ntnu.no> writes:
> 
> > But the read-time vs run-time (or compile-time) distinction makes more
> > sense to me.  If a python function references foo.bar then by changing
> > the value of foo I can make the function refer to a different foo.bar,
[...]
> Well, not quite. It will still use the same /symbol/ foo:bar, but its
> SYMBOL-FUNCTION may change, of course.

Rereading your paragraph, it should be noted that changing the
/package name/ of any referenced packages afterwards (which is closer
to changing the value of "foo", i.e. having foo refer to another
module) indeed won't affect users. I.e., after the previous example:

* (defpackage p3 (:use :cl))
#<PACKAGE "P3">
* (defun p3::foo () :something-completely-different)
P3::FOO
* (rename-package :p1 :p-old)
#<PACKAGE "P-OLD">
* (rename-package :p3 :p1)
#<PACKAGE "P1">
* (bar)
:THIRD-DEFINITION




More information about the Python-list mailing list