[Python-Dev] New and Improved Import Hooks

Steve Holden sholden@holdenweb.com
Fri, 6 Dec 2002 08:31:07 -0500


> "Steve Holden" <sholden@holdenweb.com> writes:
>
> > > >Should be "importing_module_from_dlls".
> > >
> > > I still don't understand. Is that some feature of Python?
> > >
> > I think Wiktor is referring to extensions, which under Windows are often
> > provided as .pyd DLLs.
>
> Yes, but then I understand how that is related to zipfile imports: A
> .pyd provides only a single module. A .zip file must supply many
> modules.
>
> > A quick look at my own code base, admittedly puny, reveals no statements
> > that would break were non-strings to be added to sys.path. Is there some
way
> > to trap assignments to sys.path so a warning could be issued if
sufficiently
> > un-stringy elements were discovered in it?
>
> This isn't really possible, as this is just a dict
> modification. You'ld also have to catch assignments to
> sys.__dict__['path']
>

Indeed. But if sys were an instance of some class, rather than a module, we
could trap the assignments in its __setattr__ ... hmm, that's far too
radical. Pity.

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com
-----------------------------------------------------------------------