I'm working on a module that produces highlighted HTML-Versions of Python code. This will eventually be used by this tool to allow easier browsing of source code. You can then put all the needed imports at the top of a source file, and the modules only get imported when they are actually referenced. This little module gives you the needed import code for this to happen. It self installs upon loading.
All subsequent imports become lazy.
Using the standard imp module to alter the import behaviour of Python together with some class glue, modules are wrapped into objects, with all their abilities and features. One implementation is the lazy import feature. Note that the module currently does not handle packages correctly. It does what I want it to do, so I don't think I'll put much more work into it. A much faster way is to use a list of substrings, which then get joined into a bigger one with one single call to string.join.