Web development with Python 3.1

Rami Chowdhury rami.chowdhury at gmail.com
Wed Oct 28 23:43:51 CET 2009

On Wed, 28 Oct 2009 14:15:54 -0700, Dotan Cohen <dotancohen at gmail.com>  

>> What do you mean by "in the middle of the page"? Do you mean, for  
>> instance,
>> the behavior of "middle.php" in the following PHP example:
>> <?php
>> include_once("beginning.inc.php");
>> include_once("middle.php");
>> include_once("end.inc.php");
>> ?>
>> Is that what you are after?
> Yes, that is what I am after. For instance, if one were to look at the
> source code of http://dotancohen.com they would see "<!-- / HEADER
> -->". All the HTML up to that point was output by bigginin.inc.php.
> Similarly, near the end exists "<div class="bottomfiller">", all the
> code from there is generated by end.inc.php. These two files are
> included in every page of the site.

I think you're misunderstanding how Python and the web work together.  
Python is not PHP -- it was not designed to replace HTML, and it is in  
itself not a templating language. If you would like to use Python code  
embedded in HTML, the way PHP is typically used, you may want to look at  
Python Server Pages  
(http://www.modpython.org/live/current/doc-html/pyapi-psp.html) which are  
provided by mod_python.

Just so you know (as I think this is what is causing much of the  
misunderstanding here), most Python web frameworks *do not* subscribe to  
the traditional model of the web, where URLs represent files on a server.  
(In the case of PHP, Python Server Pages, or CGI scripts, these are  
augmented files which are executed by the server, but it's the same  
concept). Instead, they typically map URLs to arbitrary code.

Rami Chowdhury
"Never attribute to malice that which can be attributed to stupidity" --  
Hanlon's Razor
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)

More information about the Python-list mailing list