changing `import' to use other than .py

Gordon McMillan gmcm at
Wed Oct 10 14:32:35 CEST 2001

Harald Kirsch wrote:
> Is there a way to tell import (or __import__) to
>   a) use a different extension than .py when searching for files

Yes. This has been done (by Quixote, dpython and one of the CORBA

>   b) not to compile that file while/after importing

All of the above do their own compilation (either because the
source is not Python syntax, or - with dpython - because the
compilation is done differently).

You have a number of choices of how you do it (ihooks, imputil...).
But importing is tricky and fragile, so the first thing I'd 
consider is pre-processing (the only real difference being that
an import hook will allow you to do this on demand).

- Gordon

More information about the Python-list mailing list