[Python-Dev] imputil and modulefinder replacements

Michael McLay mclay@nist.gov
Fri, 5 Oct 2001 13:28:06 -0400


On Friday 05 October 2001 12:19 pm, Greg Ward wrote:
> On 05 October 2001, M.-A. Lemburg said:

> The only import hook I'm familiar with is Quixote, where we have defined
> a Python dialect called PTL (Python Template Language, used to embed
> HTML [or other text] in Python).  Install Quixote's import hook, and you
> can import .ptl files just like .py files.  It's very handy.  Out of
> curiosity, does anyone know of any other import hooks like this out
> there -- ie. import something that is not strictly Python.  

The dpython interpreter I wrote this summer would tokenize .dp files that 
were in the Python path. If the alternative suffix was detected the Python 
interpreter would use the dpython tokenizer.  The dpython tokenizer 
would generate decimal numbers instead of binary numbers as the default for 
float and int literals.  I didn't use the import hooks.  I built the .dp file 
recognition into the interpreter at the point where it evaluates the suffix 
of the file name and compairs it to the filedesc struct.  

When I discussed the implementation of dpython at the ZPUG meeting I 
joked about extending the concept to add bytecode generators for JavaScript 
and Visual Basic modules.  The work required to add JavaScript would probably 
be reasonable.  It might help get Python used anywhere JavaScript is used.  

There has also been some interest at NIST and NASA in building modules to 
parse meta languages such as XML Schema, KIF, and Express and directly 
generate Python bytecodes.