can regular ol' python do a php include?

Fredrik Lundh fredrik at
Tue Oct 10 17:55:47 CEST 2006

John Salerno wrote:

> Spoke too soon maybe. Does using the above mean that I have to create an 
> entire Python file rather than an HTML file? What I'm looking for is to 
> be able to use pure HTML, but just stick in a line of Python when I need 
> to include something.

"include" is a PHP statement, not an HTML statement.

> It doesn't seem to work this way though, unless I'm doing something wrong.

Python CGI scripts are Python programs that generate output, not HTML 
files that are run though some HTML filter thingie on the way out.  if 
you want the latter, you have to use a suitable template engine, and 
configure your web server to run your files through that engine on the 
way out.  mod_python is one such tool:

spyce is another one:


More information about the Python-list mailing list