import hooks

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Apr 16 02:02:04 EDT 2008


En Tue, 15 Apr 2008 22:14:18 -0300, Patrick Stinson  
<patrickkidd.lists at gmail.com> escribió:

> What's the current way to install an import hook? I've got an embedded  
> app
> that has a few scripts that I want to import each other, but that are  
> not in
> sys.modules. I intentionally keep them out of sys.modules because their
> names will not be unique across the app. They will, however, be unique
> between scripts that I (do* want to see each other).
> Basically, I want to return a certain module from a name-based filter.  
> I've
> already written a type in C with find_module and load_module, but it  
> doesn't
> seem to work when I add the type to sys.path_hooks. I wrote a simple one
> that worked just fine from a pure script file run through python.exe.

 From that description alone I can't say what's happening; you should post  
some code.
Also, if your importer isn't disk-based, perhaps using sys.meta_path is  
better.

-- 
Gabriel Genellina




More information about the Python-list mailing list