Python as replacement for PHP?
Skip Montanaro
skip at pobox.com
Fri Feb 27 16:20:09 EST 2004
Erik> 1) PHP seems to have a pretty good integration/driver with
Erik> PostgreSQL. If we were to switch to Python, what
Erik> modules/drivers are available to talk to PosgreSQL and is it as
Erik> functional as PHP's support?
I use psycopg and like it. There are a couple others as well.
Erik> 3) Does Python have an analog to strtotime()? (For those not
Erik> familiar with that function, it converts a wide range of date
Erik> formats as string into time_t value. Can handle things like
Erik> "now", "+24 hours", "-3 days", "yesterday 06:00PM MST",
Erik> "January 23, 2004", "2004-02-26 18:00:00 -07", etc.)
Marc-Andre Lemburg's mxDateTime might be the closest you'll get to such wide
ranging formats.
Erik> 4) I am vaguely aware of Apache's modpython. We are currently
Erik> running apache, but I'm real green when it comes to
Erik> configuring/running/managing Apache. I don't really understand
Erik> what all modpython does for me. Generally allows Apache to
Erik> foist off an HTTP request on a Python script to handle I
Erik> assume, but maybe some kind soul can better inform me about
Erik> what all modpython really does for me?
It essentially avoids process creation and Python startup overhead. Both
can be significant performance barriers on heavily loaded systems.
Erik> 5) A PHP script can freely jump in and out of static HTML and
Erik> script code with <?php ?> tags. This is sometimes handy. Can
Erik> you do the same thing with Python?
There are lots of different Python-based templating systems. I like
Quixote. It's roughly the inverse of the way most systems do the
HTML/<language> mind-meld. Instead of Python-in-HTML it's HTML-in-Python.
There are other systems with which I am not aware. Cheetah and PSP come to
mind.
Erik> 6) Debugging: I'm aware there is a debugger for Python - I haven't
Erik> really used it. Maybe there is a better way to do this using
Erik> PHP, but right now when a PHP script isn't working right, I'm
Erik> reduced to print statements and just re-running the script. Do
Erik> you know a better way to do this in PHP? If I were doing
Erik> things in Python, is there an easy way to generate an HTTP
Erik> request from my browser, but stop the generating script and
Erik> analyze it in a Python debugger?
Inserting print statements is a pretty common debugging technique in Python
as well. Also, take a look at the cgitb module.
Skip
More information about the Python-list
mailing list