[Python-Dev] intra-package mutual imports fail: "from <pkg> import <mod>"

Gisle Aas gisle@ActiveState.com
02 Jun 2002 09:44:25 -0700


"Matthias Urlichs" <smurf@noris.de> writes:

> Gisle Aas:
> > Perl doesn't add references to names.  It imports direct reference as
> > well.
> 
> What I meant to say was: Perl shares the actual symbol table slot when you
> import something;

Wrong.  If you do:

   package Bar;
   use Foo qw(foo);

Then you end up with \&Bar::foo and \&Foo:foo pointing to the same
function object, but the symbol table slots are independent.  Is is
exactly the same situation you would have in Python with two namespace
dicts pointing to the same function object.

But you can achieve sharing by explicit import of the symbol (aka
glob) using something like:

   use Foo qw(*foo);

Regards,
Gisle Aas