import hook

Jeremy Sanders jeremy+complangpython at jeremysanders.net
Sun Jun 11 16:57:07 CEST 2006


Hi - Is it possible to override the import process so that if in my program
I do

import foo.bar

Python will look for bar in a directory which isn't called foo?

I want my module/program to be able to be run without being installed in
site-packages, so by doing "import foo.bar", it should start looking for
bar in the current directory which could be called "foo-0.43".

I've tried overriding __import__, chopping out "foo." from package names,
but that tends to break. I've also tried overriding imp.find_module() but
Python never appears to use my version.

Any ideas?

Thanks

Jeremy

-- 
Jeremy Sanders
http://www.jeremysanders.net/



More information about the Python-list mailing list