Python Hypertext Preprocessor

PyHP allows use of the Python programming language in scripts similar to PHP. PyHP uses the Python 2.0 language to parse elements embedded in an HTML page.

Note to users

When I started this, I was enamoured with PHP. I've since discovered that embedding code in HTML does not seem like the most logical way to do things. If someone wants to pick this up, email me. In the mean time, if you want a truely novel approach to web design with Python, check out the very cool Quixote framework.

Why another one?

I wanted a small, fast, hypertext preprocessor that used the world's greatest scripting language, Python, as its base. There was another program out there that did this, PMZ, but I quickly found what I believed to be shortcomings in it.
Namespace polution
My main problem with PMZ is that it does not execute its programs in a seperate name space. If you define a variable name 'fields' in the global namespace then PMZ will crap out because there is a variable of that name that is of vital importance to the interpreter itself. I did not find this to be acceptable, and Python 2.0's InteractiveInterpreter class made it easy to get around this in PyHP.
PyHP was designed for use with Apache's mod_python. It will run just fine as a standalone program, but it has been designed to be accelerated under mod_python by automatically caching modules that have been imported and supporting the manual caching of variables as well
Header specification
PMZ has a fixed set of headers that cannot be modified by a PMZ script. PyHP allows script writers to specify what headers are attached to their documents, even to do so in the middle of the HTML file.


Download the latest version. Be warned that PyHP is still very much beta.

Change Log

You will also need to go download mod_python if you wish to run the accelerated version.


View the manual online.