Relative Imports, why the hell is it so hard?
kay.schluehr at gmx.net
Tue Mar 31 21:08:23 CEST 2009
On 31 Mrz., 20:50, Terry Reedy <tjre... at udel.edu> wrote:
> Nothing is added to sys.modules, except the __main__ module, unless
> imported (which so are on startup).
Yes. The startup process is opaque but at least user defined modules
are not accidentally imported.
> > Although the ceremony has been performed
> > basically correct the interpreter god is not pacified and doesn't
> > respond.
> But the import 'ceremony' has not been performed.
There is no import ceremony. Imports are just stated in the source.
There is a package ceremony for whatever reasons.
> > But why not? Because it looks up for *living* imported
> > packages in the module cache ( in sys.modules ).
> > I don't think there is any particular design idea behind it. The
> > module cache is just a simple flat dictionary; a no-brainer to
> > implement and efficient for look ups.
> This all dates to the time before packages and imports from zip files
> and such.
> > But it counteracts a domain model.
> What is that?
Object oriented programming.
> > All you are left with is those Finders, Loaders and Importers
> > in Brett Cannons importlib. Everything remains deeply mysterious and I
> > don't wonder that it took long for him to work this out.
> And your proposal is?
I have still more questions than answers.
More information about the Python-list