can regular ol' python do a php include?

Fredrik Lundh fredrik at pythonware.com
Tue Oct 10 11:55:47 EDT 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:

  http://www.onlamp.com/pub/a/python/2004/02/26/python_server_pages.html

spyce is another one:

  http://spyce.sourceforge.net/

</F>




More information about the Python-list mailing list