[Python-Dev] New and Improved Import Hooks

Wiktor Sadowski Wiktor Sadowski" <art@wiktorsadowski.com
Wed, 4 Dec 2002 20:25:24 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_0748_01C29BD3.465E8700
Content-Type: text/plain;
	charset="windows-1250"
Content-Transfer-Encoding: quoted-printable

> I think we shouldn't use sys.path for zip archives.
>Why do you think so?
IMO:Why make changes if it's not necessary .?

> Why not "copy" importing_modules_from_dlls(pyds) mechanism?
>What do you mean by that? What is "importing_modules_from_dlls"?

Should be "importing_module_from_dlls".

>If you mean "one .pyd file is one Python module", then this approach
>won't work for .zip files:People want many .py modules in a single .zip
>file.

It will work if handled by the zip importer.

As for ARCHIVES directory: a "virtual" path for all zip files could be =
built for lookup.
Importing from __init__.py could be done explicitly with:

from MyArchive_with_many_modules import MyModule
or
import MyArchive_with_many_modules.MyModule

where  MyArchive_with_many_modules is MyArchive_with_many_modules.zip=20
in the same directory (or in ARCHIVES)

Regards,
Wiktor=20












------=_NextPart_000_0748_01C29BD3.465E8700
Content-Type: text/html;
	charset="windows-1250"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1250">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>&gt; I think we shouldn't use sys.path for zip archives.<BR>&gt;Why =
do you=20
think so?</DIV>
<DIV>IMO:Why make changes if&nbsp;it's not necessary .?</DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3><FONT=20
face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&gt; Why not "copy" importing_modules_from_dlls(pyds)=20
mechanism?<BR>&gt;What do you mean by that? What is=20
"importing_modules_from_dlls"?</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>Should be "importing_module_from_dlls".</DIV>
<DIV><BR>&gt;If you mean "one .pyd file is one Python module", then this =

approach<BR>&gt;won't work for .zip files:People want many .py modules =
in a=20
single .zip<BR>&gt;file.</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>It will work if handled by the zip importer.</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>As for ARCHIVES directory: a "virtual" path for all zip files could =
be=20
built for lookup.</DIV>
<DIV>Importing from __init__.py could be done explicitly with:</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>from MyArchive_with_many_modules import MyModule</DIV>
<DIV>or</DIV>
<DIV>import&nbsp;MyArchive_with_many_modules.MyModule</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>where&nbsp;&nbsp;MyArchive_with_many_modules is=20
MyArchive_with_many_modules.zip </DIV>
<DIV>in the same directory (or in ARCHIVES)</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>Regards,</DIV>
<DIV>Wiktor&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR><BR></FONT><BR></DIV></FONT></BODY></HTML>

------=_NextPart_000_0748_01C29BD3.465E8700--