confusion about package/module imports
danebarney at gmail.com
Tue Jan 1 23:35:14 CET 2008
Thanks very much for your helpful response!
> You'll see that b is executed (making module __main__),
> (1) it imports pkg.subpkg.a,
> (2) which is accomplished by importing pkg (successfully),
> (3) then by importing pkg.subpkg
> (4) which imports pkg.subpkg.a (successfully)
> (5) and then imports pkg.subpkg.b
> (6) which then attempts to import pkg.subpkg.a
What I'm not really understanding here is why this fails at lines (5)
and (6). If pkg.subpkg.a has already been successfully imported at
line (4), then (6) should be detected as a duplicate import and just
be skipped, right? So the import at line (5) should succeed.
More information about the Python-list