importhook default behavior

Pete Shinners pete at
Thu Jun 17 16:51:18 CEST 2004

I have a situation where I am wanting strict control over handling 
multiple installed versions of the same modules.

All I really want to do is map a package name to a directory special 
directory, and from there allow the standard python importing to continue.

I've got it working for the simple case, but it seems up to my 
importhook to duplicate a lot of the standard import functionality. 
Especially if it comes to importing subpackages of packages inside my 
magic versioned package.

What I'd like to do is determine the real directory to use, and make a 
call to the regular python importing tools. Is there somewhere in Python 
I can find an importhook object that represents the default python behavior?

I suppose the ZipImport has all the functionality I'd need, but it seems 
odd to be recode all that logic (.pyc or .pyo first, .dll or .so, .py, 
or if directory look for __init__.[anyext]. recursive). Maybe that isn't 
so hard after all.

More information about the Python-list mailing list