[Python-Dev] New and Improved Import Hooks

Martin v. Löwis martin@v.loewis.de
06 Dec 2002 00:17:44 +0100


"Wiktor Sadowski" <art@wiktorsadowski.com> writes:

> >I still don't understand. Is that some feature of Python?
> 
> Under Windows you can put a Module.pyd into Python/DLLs directory and:
> import Module

I see. Notice that there is nothing special about the DLLs
directory. Instead, you can have .pyd files anywhere on sys.path, and
the DLLs directory is included in sys.path - that's why .pyd files are
found in the DLLs directory.

> >If I have "python23.zip", and do
> 
> >import httplib
[...]
> >So you could only zip entire packages? 
> No.

All your explanations indicate otherwise.

> "from MyArchive import MyModule"
> would be resolved by zip importer as:
> if there is MyModule in MyArchive.zip then then import MyModule
> (means extract and import)
> 
> and
> import Module:
> if Module.zip contains Module import Module

So if I do

import httplib

it will check httplib.zip. Correct? That won't help, since httplib is
in python23.zip, not in httplib.zip.

According to your proposal, I would have to write

from python23 import httplib

But I don't want to, since httplib is a toplevel module, which is not
included in a python23 package.

Regards,
Martin