Python

Moderators: None (Apply to moderate this forum)
Number of threads: 473
Number of posts: 1165

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
python as cgi Posted by Gregry2 on 25 Jun 2006 at 8:52 PM
I read that python is as capable as a cgi script as php and perl, and I would like to think so as well since I like python and noe it better than php or perl...but is it really true? What is python best for anyway?

{2}rIng
Report
Re: python as cgi Posted by infidel on 27 Jun 2006 at 7:58 AM
: I read that python is as capable as a cgi script as php and perl, and I would like to think so as well since I like python and noe it better than php or perl...but is it really true? What is python best for anyway?

Python is good for whatever you want to do with it, except for the kinds of things that any other interpreted language is not good at, like operating systems or low-level things like that.

There are tons of examples on writing CGI in python. It even comes with a couple of libraries that help out.

Technically you can write a CGI program in any language, so you might as well pick one that you like.


infidel

$ select * from users where clue > 0
no rows returned


Report
Re: python as cgi Posted by Gregry2 on 27 Jun 2006 at 6:52 PM
: : I read that python is as capable as a cgi script as php and perl, and I would like to think so as well since I like python and noe it better than php or perl...but is it really true? What is python best for anyway?
:
: Python is good for whatever you want to do with it, except for the kinds of things that any other interpreted language is not good at, like operating systems or low-level things like that.
:
: There are tons of examples on writing CGI in python. It even comes with a couple of libraries that help out.
:
: Technically you can write a CGI program in any language, so you might as well pick one that you like.
:
:
: infidel
:
:
: $ select * from users where clue > 0
: no rows returned
: 

:
:

I've never programmed in php or perl, and I'm not saying there are any differences, but does python have any edge vs. these langs in cgi?
{2}rIng
Report
Re: python as cgi Posted by infidel on 28 Jun 2006 at 8:49 AM
: I've never programmed in php or perl, and I'm not saying there are any differences, but does python have any edge vs. these langs in cgi?

I'm not sure what kind of "edge" you're looking for. There's nothing really special about CGI. All CGI really means is that the webserver calls an external executable program each time that URL is requested, sets up the environment for it, and then reads that program's output to send back to the client. PHP is different because there's a module *in the webserver* that interprets the PHP code and renders the HTML output. There are also modules (for Apache, at least) that let you interpret Perl or Python code within the webserver process similar to PHP, but that is something else entirely from CGI.

I know that Python comes with the cgi and cgitb modules which have some "helper" objects in them for getting things like form input and displaying pretty error tracebacks. I'm sure Perl has useful libraries that help with CGI stuff like that as well. Aside from HTTP-specific things like form input (which is ultimately nothing more than environment variables and standard input), a CGI program is just a regular program that writes output to stdout (in Python you use the "print" statement).

So use what you know and like.

If you want to do something where your python code is actually running in the server then I personally recommend CherryPy. There's also TurboGears which runs on CherryPy but comes with all kinds of extra stuff to get you started. The standard documentation that comes with Python explains the cgi and cgitb modules well enough to get started with simple CGI.


infidel

$ select * from users where clue > 0
no rows returned





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.