CGI with Python: advantages?

Moshe Zadka moshez at math.huji.ac.il
Sun Aug 6 06:30:46 EDT 2000


On Sun, 6 Aug 2000, Mimmo wrote:

> The question is: is Python a good language for CGI scripting?

Yes! But that's not the question <wink>, the question is CGI scripting 
good? I'm sure Cameron will chime in with the usual "CGI is not obsolete
yet", but you might want to explore other solutions, both within and
without Python: Zope, Enhydra, Java Servletes, Perl's HTML::Mason, 
PHP, mod_snake or even more exotic stuff like custom HTTP servers in 
Python (CGIHTTPServer.py) or Tcl.

> Does it offer something more (speed, efficency or whatever else) than
> Perl or other languages used to write this kind of scripts?

If you're looking for speed and efficiency, I think the main overhead in
most CGI scripts is the prohibitive start-up time. While Python's start-up
time is longer then Python, they are pretty close -- if you're starting
to optimize, please have a look at the other solutions I've suggested.

> Or can I
> still use Perl for my CGIs and use Python for other things?

Ummmm......I'm sorry. Once you start using Python, you have to use it
everywhere. Using another language that starts with a P is completely out
of the question! We might make a special exception in your case, provided
you donate a large sum of money in small and unmarked bills to the PSU.
I suggest doing this fast, because once the clause enters the Python
licence, I'm afraid we won't be able to help you at all.
 
> Maybe this will sound as a quite "stupid" question, but I'd like to have
> some informations from people who use it for this kind of programming!

I've programmed some CGIs in Python, and it is very easy. However, do note
that Python's cgi.py is closer to Perl's CGI::Lite  then to Perl's CGI.pm.
If you want cool HTML generation, you should get the htmlgen module. If
you find this is really a need, consider if you're not mixing code with
graphic design and or content, and if CGI is the correct solution for you.

--
Moshe Zadka <moshez at math.huji.ac.il>
There is no IGLU cabal.
http://advogato.org/person/moshez





More information about the Python-list mailing list