Python as replacement for PHP?

Discussion in 'Python' started by Erik Johnson, Feb 27, 2004.

  1. Erik Johnson

    Erik Johnson Guest

    This is somewhat a NEWBIE question...

    My company maintains a small RDBS driven website. We currently generate
    HTML using PHP. I've hacked a bit in Python, and generally think it is a
    rather cool language. I've done Perl and like it, there are a few features
    of PHP I like but overall am not too excited about it. I have found PHP's
    strtotime() function to be quite flexible and handy and we make liberal use
    of it.

    I have not yet really "dug-in" to Python - I have dabbled and hacked a
    bit. I am advocating considering switching to Python for a number of
    reasons:

    1) I think Python is cool.
    2) We can do system administration type scripts (currently
    implemented in Perl), web page generation (PHP), and (potentially)
    client-side applications (including GUI's that make socket and/or external
    HTTP requests) in one language.
    3) Python's interactive interpreter makes it easy to try things out.
    4) PyUnit - we would like to develop a robust set of tests and be
    able to do regression testing. I'm not aware of a JUnit/PyUnit analog in
    PHP. Are you?
    5) Python has better code support for complex native data types
    (e.g., tuples, dictionaries, sequences, etc. and being able to write these
    directly in a hierarchical structure rather than building them up piecewise
    with function calls and assignments as in PHP).
    6) All the other standard evangeslistic points about why Python is
    better than <your favorite language here>, some of which may be valid to us,
    some probably not. To those that have used PHP: what am I potentially losing
    that Python really can't replace?

    So, I'm hoping there are some people out there that actually have some
    expereience with both Python & PHP and can give me some solid, informed
    advice about PHP vs. Python, in general and particularly on the following
    points: (NOT Python evangelism please: I've already heard most of it, I've
    espoused a pretty good dose myself - frankly, I'm willing to buy most of it,
    but I've got a serious business decision to make here).

    1) PHP seems to have a pretty good integration/driver with PostgreSQL.
    If we were to switch to Python, what modules/drivers are available to talk
    to PosgreSQL and is it as functional as PHP's support?

    2) Is there a way to have our cake and eat it too? That is, rather than
    being forced to ride one horse or another, can I ride both horses at once:
    is there a way to integrate PHP and Python such that I could call PHP
    functions from a Python script? I know you can always make system calls, and
    it probably wouldn't be that difficult to call an external PHP script and
    slurp up it's output from STDOUT, but my impression is that this is a pretty
    expensive thing to do (relatively) compared to generating HTML from a single
    script invocation. I'm asking if there exists some sort of single-process
    integration (e.g., something akin to Java's "native" interface where a
    program can schlep data back and forth between a Java environment and
    "native" C)?

    3) Does Python have an analog to strtotime()? (For those not familiar
    with that function, it converts a wide range of date formats as string into
    time_t value. Can handle things like "now", "+24 hours", "-3 days",
    "yesterday 06:00PM MST", "January 23, 2004", "2004-02-26 18:00:00 -07",
    etc.)

    4) I am vaguely aware of Apache's modpython. We are currently running
    apache, but I'm real green when it comes to configuring/running/managing
    Apache. I don't really understand what all modpython does for me. Generally
    allows Apache to foist off an HTTP request on a Python script to handle I
    assume, but maybe some kind soul can better inform me about what all
    modpython really does for me?

    5) A PHP script can freely jump in and out of static HTML and script
    code with <?php ?> tags. This is sometimes handy. Can you do the same thing
    with Python?

    6) Debugging: I'm aware there is a debugger for Python - I haven't
    really used it. Maybe there is a better way to do this using PHP, but right
    now when a PHP script isn't working right, I'm reduced to print statements
    and just re-running the script. Do you know a better way to do this in PHP?
    If I were doing things in Python, is there an easy way to generate an HTTP
    request from my browser, but stop the generating script and analyze it in a
    Python debugger?

    7) This goes back to #2, but we are looking at purchasing a PHP graphing
    package: http://www.aditus.nu/jpgraph/ If we could easily call PHP from
    within Python, then I guess that is a no brainer: we can use the PHP
    package. If not, then we are left answering the quesiton, can we call it as
    a forked process, and if so, is that too expensive? Do you know of
    comparable packages for Python?


    I think that's it for now. Thank you for taking the time to read my post
    and many thanks in advance to anyone who would be so kind as to reply.
    (direct response to ej at wellkeeper dot com greatly appreciated).

    -ej
     
    Erik Johnson, Feb 27, 2004
    #1
    1. Advertising

  2. Erik Johnson

    Bart Nessux Guest

    Erik Johnson wrote:
    > This is somewhat a NEWBIE question...
    >
    > My company maintains a small RDBS driven website. We currently generate
    > HTML using PHP. I've hacked a bit in Python, and generally think it is a
    > rather cool language. I've done Perl and like it, there are a few features
    > of PHP I like but overall am not too excited about it. I have found PHP's
    > strtotime() function to be quite flexible and handy and we make liberal use
    > of it.
    > 6) All the other standard evangeslistic points about why Python is
    > better than <your favorite language here>, some of which may be valid to us,
    > some probably not. To those that have used PHP: what am I potentially losing
    > that Python really can't replace?
    >
    > So, I'm hoping there are some people out there that actually have some
    > expereience with both Python & PHP and can give me some solid, informed
    > advice about PHP vs. Python, in general and particularly on the following
    > points: (NOT Python evangelism please: I've already heard most of it, I've
    > espoused a pretty good dose myself - frankly, I'm willing to buy most of it,
    > but I've got a serious business decision to make here).


    When it comes to dynamic, DB driven sites, PHP is the only way to go.
    Python is not even close to being suited for this task. PHP claims to be
    a general-purpose language, but I do not know anyone who uses it for
    anything other than dynamic Web programming.

    A serious business decision? PHP would be the only winner here. You
    should not even be considering another language for this, it borders on
    stupidity. We use Python & C for backend processing, systems
    administration and other general programming tasks, but the front-end
    (the Websites) are pure PHP.
     
    Bart Nessux, Feb 27, 2004
    #2
    1. Advertising

  3. Erik Johnson

    Phil Roberts Guest

    With total disregard for any kind of safety measures "Erik
    Johnson" <> leapt forth and uttered:

    > 4) PyUnit - we would like to develop a robust set of tests and
    > be able to do regression testing. I'm not aware of a
    > JUnit/PyUnit analog in PHP. Are you?
    >


    SimpleTest: http://www.lastcraft.com/simple_test.php
    PHPUnit (1):http://www.students.cs.uu.nl/people/voostind/index.php?
    page=software
    PHPUnit (2):http://pear.php.net/package/PHPUnit
    PHPUnit (3):http://phpunit.sourceforge.net/

    Having three test suites all called PHPUnit is a tad confusing...


    --
    Phil Roberts | Dork Pretending To Be Hard | http://www.flatnet.net/
     
    Phil Roberts, Feb 27, 2004
    #3
  4. 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
     
    Skip Montanaro, Feb 27, 2004
    #4
  5. Erik Johnson

    CountScubula Guest

    "Erik Johnson" <> wrote in message
    news:...
    > This is somewhat a NEWBIE question...
    > (snip)
    > I have not yet really "dug-in" to Python - I have dabbled and hacked a
    > bit. I am advocating considering switching to Python for a number of
    > reasons:
    >
    > 1) I think Python is cool.
    > 2) We can do system administration type scripts (currently
    > implemented in Perl), web page generation (PHP), and (potentially)
    > client-side applications (including GUI's that make socket and/or external
    > HTTP requests) in one language.
    > 3) Python's interactive interpreter makes it easy to try things

    out.
    > 4) PyUnit - we would like to develop a robust set of tests and be
    > able to do regression testing. I'm not aware of a JUnit/PyUnit analog in
    > PHP. Are you?
    > 5) Python has better code support for complex native data types
    > (e.g., tuples, dictionaries, sequences, etc. and being able to write these
    > directly in a hierarchical structure rather than building them up

    piecewise
    > with function calls and assignments as in PHP).
    > 6) All the other standard evangeslistic points about why Python is
    > better than <your favorite language here>, some of which may be valid to

    us,
    > some probably not. To those that have used PHP: what am I potentially

    losing
    > that Python really can't replace?
    >
    > (snip)
    >
    > -ej
    >
    >



    You should use what is best for you, but trying to settle on one laguage for
    everthing is not a good idea, you will end uplocking yourself into more code
    than you need sometimes.

    Python is gread for server stuff, and GUI stuff, but for dynamic
    intergration of html/script, PHP wins hands down.

    Now I also use PHP for everything else (except GUI stuff) on servers, almost
    all of my shell scripts are in php, along with autoresponders, mail filters,
    data backup servers, etc..

    But again, use what is quick/fast/simple to implment for you. I use to use
    perl for everthing under the sun, then slowly moved to php, not becouse it
    was cool, but rather easier to set up, and with added functions designed for
    dynamic site ingration.

    You also need to look at what each language was desgined for, sure I can
    write a dynamic web page in bash or korn, but why? Perl was written to do
    large extraction and reporting of text files, Python was written as a server
    language, PHP was design specificly for dynamic/integration of web pages.

    Ok, I'm done now.

    --
    Mike Bradley
    http://www.gzentools.com -- free online php tools
     
    CountScubula, Feb 27, 2004
    #5
  6. Erik Johnson

    Dave Brueck Guest

    Bart wrote:
    > Erik Johnson wrote:
    > > This is somewhat a NEWBIE question...
    > >
    > > My company maintains a small RDBS driven website. We currently generate
    > > HTML using PHP. I've hacked a bit in Python, and generally think it is a
    > > rather cool language. I've done Perl and like it, there are a few features
    > > of PHP I like but overall am not too excited about it. I have found PHP's
    > > strtotime() function to be quite flexible and handy and we make liberal use
    > > of it.
    > > 6) All the other standard evangeslistic points about why Python is
    > > better than <your favorite language here>, some of which may be valid to

    us,
    > > some probably not. To those that have used PHP: what am I potentially

    losing
    > > that Python really can't replace?
    > >
    > > So, I'm hoping there are some people out there that actually have some
    > > expereience with both Python & PHP and can give me some solid, informed
    > > advice about PHP vs. Python, in general and particularly on the following
    > > points: (NOT Python evangelism please: I've already heard most of it, I've
    > > espoused a pretty good dose myself - frankly, I'm willing to buy most of

    it,
    > > but I've got a serious business decision to make here).

    >
    > When it comes to dynamic, DB driven sites, PHP is the only way to go.
    > Python is not even close to being suited for this task. PHP claims to be
    > a general-purpose language, but I do not know anyone who uses it for
    > anything other than dynamic Web programming.
    >
    > A serious business decision? PHP would be the only winner here. You
    > should not even be considering another language for this, it borders on
    > stupidity.


    What on earth?! Each is entitled to his or her own opinion, but this is a bit
    over the top. The OP would do well to search the Google archives as this topic
    has come up many times, and there are many who disagree with the above opinion.
    Even if in the end the OP decided to stick with PHP (personally I wouldn't),
    considering Python definitely does _not_ border on stupidity.

    -Dave
     
    Dave Brueck, Feb 27, 2004
    #6
  7. Erik Johnson

    Bart Nessux Guest

    Dave Brueck wrote:

    > Bart wrote:
    >> Erik Johnson wrote:
    >> > This is somewhat a NEWBIE question...
    >> >
    >> > My company maintains a small RDBS driven website. We currently
    >> > generate
    >> > HTML using PHP. I've hacked a bit in Python, and generally think it is
    >> > a rather cool language. I've done Perl and like it, there are a few
    >> > features of PHP I like but overall am not too excited about it. I have
    >> > found PHP's strtotime() function to be quite flexible and handy and we
    >> > make liberal use of it.
    >> > 6) All the other standard evangeslistic points about why Python
    >> > is
    >> > better than <your favorite language here>, some of which may be valid
    >> > to

    > us,
    >> > some probably not. To those that have used PHP: what am I potentially

    > losing
    >> > that Python really can't replace?
    >> >
    >> > So, I'm hoping there are some people out there that actually have
    >> > some
    >> > expereience with both Python & PHP and can give me some solid, informed
    >> > advice about PHP vs. Python, in general and particularly on the
    >> > following points: (NOT Python evangelism please: I've already heard
    >> > most of it, I've espoused a pretty good dose myself - frankly, I'm
    >> > willing to buy most of

    > it,
    >> > but I've got a serious business decision to make here).

    >>
    >> When it comes to dynamic, DB driven sites, PHP is the only way to go.
    >> Python is not even close to being suited for this task. PHP claims to be
    >> a general-purpose language, but I do not know anyone who uses it for
    >> anything other than dynamic Web programming.
    >>
    >> A serious business decision? PHP would be the only winner here. You
    >> should not even be considering another language for this, it borders on
    >> stupidity.

    >
    > What on earth?! Each is entitled to his or her own opinion, but this is a
    > bit over the top. The OP would do well to search the Google archives as
    > this topic has come up many times, and there are many who disagree with
    > the above opinion. Even if in the end the OP decided to stick with PHP
    > (personally I wouldn't), considering Python definitely does _not_ border
    > on stupidity.
    >
    > -Dave


    Sorry, I disagree. As a business decision, it does border on stupidity. Why
    contemplate doing something with Python that would be tedious and difficult
    at best when PHP can do this task easily and quickly??? From a business
    (read practical point of view) it's stupid. From a religious (Mac fanatic
    like point of view), it makes sense.

    The OP spoke of a DB driven dynamic Web site. One cannot think of such a
    thing without naturally thinking of PHP... python should not even come to
    mind for this task. Backend/server-side processing, sure, but not on the
    frontend. Use the RIGHT tool for the job. Python isn't the right tool here.
     
    Bart Nessux, Feb 27, 2004
    #7
  8. Bart Nessux wrote:

    > When it comes to dynamic, DB driven sites, PHP is the only way to go.
    > Python is not even close to being suited for this task.


    WTF??

    --Irmen
     
    Irmen de Jong, Feb 27, 2004
    #8
  9. Erik Johnson

    Dave Brueck Guest

    Bart wrote:
    > Dave Brueck wrote:
    >
    > > Bart wrote:
    > >> Erik Johnson wrote:

    [snip]
    > >> When it comes to dynamic, DB driven sites, PHP is the only way to go.
    > >> Python is not even close to being suited for this task. PHP claims to be
    > >> a general-purpose language, but I do not know anyone who uses it for
    > >> anything other than dynamic Web programming.
    > >>
    > >> A serious business decision? PHP would be the only winner here. You
    > >> should not even be considering another language for this, it borders on
    > >> stupidity.

    > >
    > > What on earth?! Each is entitled to his or her own opinion, but this is a
    > > bit over the top. The OP would do well to search the Google archives as
    > > this topic has come up many times, and there are many who disagree with
    > > the above opinion. Even if in the end the OP decided to stick with PHP
    > > (personally I wouldn't), considering Python definitely does _not_ border
    > > on stupidity.
    > >
    > > -Dave

    >
    > Sorry, I disagree. As a business decision, it does border on stupidity. Why
    > contemplate doing something with Python that would be tedious and difficult
    > at best when PHP can do this task easily and quickly???


    Specifically which Python templating language(s) have you tried and found to be
    "tedious and difficult" to use? Why is it that some people, knowing both PHP
    and Python, opt for Python? It's gotta be something more than their own
    stupidity. :)

    ISTM you're way overstating the gap, if there is one in the general sense. It's
    trivial to think of cases where PHP would be the "right" choice and others
    where Python would be the "right" choice, so it's hard to put much stock in any
    claim that it's so black-and-white, especially when you know so little of the
    OP's requirements. Is it one of those "nobody ever got fired for buying IBM"
    things? :) I can believe that for some DB driven dynamic web sites PHP would be
    better suited, but *always*? No way.

    > The OP spoke of a DB driven dynamic Web site. One cannot think of such a
    > thing without naturally thinking of PHP... python should not even come to
    > mind for this task.
    > Backend/server-side processing, sure, but not on the
    > frontend. Use the RIGHT tool for the job. Python isn't the right tool here.


    But why? What specifically is it about Python that makes one "stupid" for
    considering it? (and does that mean that the many people who *do* use it - and
    do so quite successfully - for such tasks are stupid?). Maybe I haven't seen
    the light yet, but it's worked pretty well for me.

    PHP has some good features, but it's certainly not perfect. Maybe it'd be okay
    if it's were your first programming language, for example, but if you are an
    experienced developer in other languages then PHP has its own bag of ...er...
    surprises (did PHP5 finally fix the horrible copy-on-assignment "feature"?).

    I have a friend who made a living for awhile as a "fireman" for PHP
    projects-turned-disasters. In assessing the root causes of the disasters, much
    of it was attributed to developer sloppiness or lack of experience, but a lot
    of it went to language oddities such as weak OO facilities or the
    over-encouragement of global variables. Overall the impression was that as PHP
    projects grow in size, they tend to get unmanageable at a rate faster than
    "normal" (compared to other languages). Anyway, I cite it only because it's a
    web developer who has more experience than I do with PHP, but who avoids it in
    his own projects due to specific experience with its problems.

    There's just no validity to making the claim that the choice is so clear-cut.
    Right tool for the job indeed!

    -Dave
     
    Dave Brueck, Feb 28, 2004
    #9
  10. Erik Johnson

    Roger Binns Guest

    > So, I'm hoping there are some people out there that actually have some
    > expereience with both Python & PHP and can give me some solid, informed
    > advice about PHP vs. Python,


    My approach is to use PHP with the Smarty templating system for the
    web front end. All program logic and "heavy" lifting (and even
    the light lifting) is done by a backend Python program accessed
    via XML-RPC. That lets me use each language for what it is best
    and most productive at.

    Testing is easier since you can do it via XML-RPC.

    Roger
     
    Roger Binns, Feb 28, 2004
    #10
  11. On Fri, 27 Feb 2004 13:50:09 -0700,
    Erik Johnson <> wrote:
    > 1) PHP seems to have a pretty good integration/driver with PostgreSQL.
    > If we were to switch to Python, what modules/drivers are available to talk
    > to PosgreSQL and is it as functional as PHP's support?


    There are several; for some reason I don't really understand, there are
    multiple Python/PostgreSQL modules. Most of them will support the standard
    DB-API described in PEP 249. Personally I use PygreSQL with Quixote as the
    web framework.

    Note that I'm one of the developers on a Python web framework called Quixote
    (www.quixote.ca), so my answers are slanted in that direction. If you're in
    the Washington DC area, I'll be giving a Quixote tutorial next weekend at a
    Linux user group meeting; see novalug.tux.org for meeting details.

    > 3) Does Python have an analog to strtotime()? (For those not familiar
    > with that function, it converts a wide range of date formats as string into
    > time_t value. Can handle things like "now", "+24 hours", "-3 days",
    > "yesterday 06:00PM MST", "January 23, 2004", "2004-02-26 18:00:00 -07",
    > etc.)


    mxDateTime has an extensive parsing module. There's a PEP for adding date
    parsing to core Python, but it may not get done for 2.4.

    > 4) I am vaguely aware of Apache's modpython. We are currently running
    > apache, but I'm real green when it comes to configuring/running/managing
    > Apache. I don't really understand what all modpython does for me. Generally


    It embeds a Python interpreter in the Apache daemon, so you can intersperse
    Python processing in Apache's request processing. There's going to be a
    mod_python tutorial at the upcoming PyCon conference; again, if you're in
    the DC area you might consider going in order to talk to existing Python/web
    developers.

    Note that embedding the interpreter in Apache isn't a requirement; you can
    also run applications using SCGI, or FastCGI instead. You'd have to carry
    out benchmarks to see which one ends up running fastest for your
    application.

    > 5) A PHP script can freely jump in and out of static HTML and script
    > code with <?php ?> tags. This is sometimes handy. Can you do the same thing
    > with Python?


    There are various templating packages available for Python, such as Cheetah
    (vaguely PHPish), ZPT (XML-based), or PTL (part of Quixote). Personally I
    don't find embedding Python code in HTML to be a good idea; it's too
    difficult to refactor, and PTL has various convenient features for
    automatically quoting HTML.

    > a forked process, and if so, is that too expensive? Do you know of
    > comparable packages for Python?


    One of the upsides of using Python is that many more non-Web-related
    packages have been written for it. Scientific programming is a significant
    application domain for Python, so several graphing packages have been
    written. You could use Reportlab for PDF generation, Chaco, Gnuplot, or Gist
    for graphing, or the Python Imaging Library for generating PNGs/JPGs.

    --amk
     
    A.M. Kuchling, Feb 28, 2004
    #11
  12. Erik Johnson

    simo Guest

    Here's how I see it (I'm a Web Developer by trade):

    PHP - excellent database integration, if you don't want to have to use
    a Java application server for database work, go with PHP. Also nice
    templating system which even the Dreamweaver morons can work with. It
    is a bit slow at times (XML-RPC/SOAP implementations stink) and has
    limited data types.

    Python - excellent GUI support (PyQt/TKinter/wxPython are sooo easy),
    best suited to rapid application development - we use it for
    prototyping cross-platform C++ apps at work, also for wrapping GUI's
    around sysadmin scripts. Plus it's easy to distribute using distutils.

    Perl - bloody fast, if you're doing lots of text processing/regex
    (e.g. XML parsing) then Perl is it, probably best for sysadmin tasks
    too. We use this for large reports at work. I love its hash handling
    and wide range of modules.

    The moral of the story is don't get locked into one technology, use
    the best tools for the job - especially if you happen to know them
    all! ;o)
     
    simo, Feb 28, 2004
    #12
  13. Bart Nessux wrote:

    ....

    > Sorry, I disagree. As a business decision, it does border on stupidity. Why
    > contemplate doing something with Python that would be tedious and difficult
    > at best when PHP can do this task easily and quickly??? From a business
    > (read practical point of view) it's stupid. From a religious (Mac fanatic
    > like point of view), it makes sense.


    Hey, god-father!
    What enables you to make such all-or-nothing statements.
    I'm very impressed by your visdom.

    Do you know on which list you are posting? No?
    It's name is Python.
    This is a list for kind, open people, known to be open for
    new ideas, always being open-minded, always talking after
    thinking, and they never do thoughtless, absolute statements.
    Especially, they never judge about things they have no idea about.

    Therefore, I think you can do a much more elaborate, much more
    detailed posting, instead of giving such statements, which
    nobody can verify, especially if (s)he has different experience.

    But I don't really care. Carry on with your own business decision.
    Fortunately, it is not my decision, and even better,
    I don't depend on it, what a relief! I'm sorry for others who do.

    > The OP spoke of a DB driven dynamic Web site. One cannot think of such a
    > thing without naturally thinking of PHP... python should not even come to
    > mind for this task. Backend/server-side processing, sure, but not on the
    > frontend. Use the RIGHT tool for the job. Python isn't the right tool here.


    Unless you give us some more proof for your statements,
    I only can say, with an unhappy absolute statement:

    *You are absolutely, completely wrong*.

    Please, try to prove your claims or spoil a different list
    with such statements. I see no evidence, since I have very
    different experience, and I *did* try more than one approach,
    before speaking up this way!

    For a more friendly reply, see Dave Brueck's post.
    I couldn't do that.

    annoyed-ly-shutting-up -- chris

    p.s.: don't start a flame war. I won't answer. I will also not
    begin to give you a private tutorial for free.
    --
    Christian Tismer :^) <mailto:>
    Mission Impossible 5oftware : Have a break! Take a ride on Python's
    Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/
    14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
    work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776
    PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
    whom do you want to sponsor today? http://www.stackless.com/
     
    Christian Tismer, Feb 28, 2004
    #13
  14. In article <>, A.M. Kuchling wrote:

    > There are several; for some reason I don't really understand, there are
    > multiple Python/PostgreSQL modules.


    The standard module that comes with Postgres was just not keeping up with
    the needs of users, so there was a ready audience for other modules. At one
    time there were 4: PyGreSQL (the "standard" one), psycopg, PyPgSQL, and
    Popy. PyGreSQL has now merged with Popy. I usually use psycopg.

    Dave Cook
     
    David M. Cook, Feb 28, 2004
    #14
  15. In article <c1oio8$rfc$>,
    Bart Nessux <> wrote:
    .
    .
    .
    >Sorry, I disagree. As a business decision, it does border on stupidity. Why
    >contemplate doing something with Python that would be tedious and difficult
    >at best when PHP can do this task easily and quickly??? From a business
    >(read practical point of view) it's stupid. From a religious (Mac fanatic
    >like point of view), it makes sense.
    >
    >The OP spoke of a DB driven dynamic Web site. One cannot think of such a
    >thing without naturally thinking of PHP... python should not even come to
    >mind for this task. Backend/server-side processing, sure, but not on the
    >frontend. Use the RIGHT tool for the job. Python isn't the right tool here.


    Shall we get out our dueling authorities? AOL thinks
    AOLserver is ideal for database-backed Web pages. NATO,
    Viacom, and the AARP use Zope. IMDB uses mod_perl. And
    so on. It's more than I can handle to believe that all
    of these developments were tedious and difficult, and
    would all have been easy and quick if only switched to
    PHP.
    --

    Cameron Laird <>
    Business: http://www.Phaseit.net
     
    Cameron Laird, Feb 28, 2004
    #15
  16. XML best practices (was: Python as replacement for PHP?)

    In article <>,
    simo <> wrote:
    .
    .
    .
    >Perl - bloody fast, if you're doing lots of text processing/regex
    >(e.g. XML parsing) then Perl is it, probably best for sysadmin tasks
    >too. We use this for large reports at work. I love its hash handling

    .
    .
    .
    Let me get this straight: your preferred vehicle for XML
    parsing is Perl regular expressions? That's ... well, it's
    a different impression than I've ever gained from anyone
    else with deep XML experience. It's sure not my first
    instinct.
    --

    Cameron Laird <>
    Business: http://www.Phaseit.net
     
    Cameron Laird, Feb 28, 2004
    #16
  17. In article <>,
    Erik Johnson <> wrote:
    .
    .
    .
    >some probably not. To those that have used PHP: what am I potentially losing
    >that Python really can't replace?

    .
    .
    .
    The first thing that comes to my mind is the panoply of
    data-management bindings PHP builds in. Those who need
    to work with a variety of hosting providers like the
    comfort of being able to count on the availability of
    their favorite DBMS.
    --

    Cameron Laird <>
    Business: http://www.Phaseit.net
     
    Cameron Laird, Feb 28, 2004
    #17
  18. Erik Johnson

    kosh Guest

    On Friday 27 February 2004 01:50 pm, Erik Johnson wrote:
    > This is somewhat a NEWBIE question...
    >
    >
    > So, I'm hoping there are some people out there that actually have some
    > expereience with both Python & PHP and can give me some solid, informed
    > advice about PHP vs. Python, in general and particularly on the following
    > points: (NOT Python evangelism please: I've already heard most of it, I've
    > espoused a pretty good dose myself - frankly, I'm willing to buy most of
    > it, but I've got a serious business decision to make here).


    Overall my company webme-eng.com has been doing websites/webapps for about 3
    years now using zope and we are very happy with it. It has been a very
    productive environment to work in and we have worked a lot on frameworks to
    make writing our stuff faster. Usually we can do in 1 week what most of our
    competitors take about 3 months to do.

    >
    > 1) PHP seems to have a pretty good integration/driver with PostgreSQL.
    > If we were to switch to Python, what modules/drivers are available to talk
    > to PosgreSQL and is it as functional as PHP's support?
    >


    I know there is postgres support in python however with zope we have worked
    pretty much exclusively with the ZODB which is an object database used in
    zope. It has worked well even for sites that have about 2GB of data.

    > 3) Does Python have an analog to strtotime()? (For those not familiar
    > with that function, it converts a wide range of date formats as string into
    > time_t value. Can handle things like "now", "+24 hours", "-3 days",
    > "yesterday 06:00PM MST", "January 23, 2004", "2004-02-26 18:00:00 -07",
    > etc.)


    Zope has a equiv to that that I think does just about all of those if not all
    I have not tested all of them and it is part of the standard DateTime object
    that is has so it is used pretty much everywhere.

    >
    > 4) I am vaguely aware of Apache's modpython. We are currently running
    > apache, but I'm real green when it comes to configuring/running/managing
    > Apache. I don't really understand what all modpython does for me. Generally
    > allows Apache to foist off an HTTP request on a Python script to handle I
    > assume, but maybe some kind soul can better inform me about what all
    > modpython really does for me?


    From what I understand mod_python just gets rid of the startup time for each
    request. Overall I prefer to have apache proxy for an app server like zope
    you might also want to look at twisted.

    >
    > 5) A PHP script can freely jump in and out of static HTML and script
    > code with <?php ?> tags. This is sometimes handy. Can you do the same
    > thing with Python?


    There are ways to do stuff like that in zope pretty easily. It allows you to
    mix in python and your code if you want but it also makes it pretty trivial
    to make the items a seperate script object and call that.

    >
    > 6) Debugging: I'm aware there is a debugger for Python - I haven't
    > really used it. Maybe there is a better way to do this using PHP, but right
    > now when a PHP script isn't working right, I'm reduced to print statements
    > and just re-running the script. Do you know a better way to do this in PHP?
    > If I were doing things in Python, is there an easy way to generate an HTTP
    > request from my browser, but stop the generating script and analyze it in a
    > Python debugger?


    Zope also logs all errors to an object called error_log in the root of the
    site which has the full python traceback and the entire contents of the web
    request that generated it. I find that a very useful feature for debugging.
    You can also attach a regular python debugger to zope and twisted (iirc).

    >
    > 7) This goes back to #2, but we are looking at purchasing a PHP
    > graphing package: http://www.aditus.nu/jpgraph/ If we could easily call
    > PHP from within Python, then I guess that is a no brainer: we can use the
    > PHP package. If not, then we are left answering the quesiton, can we call
    > it as a forked process, and if so, is that too expensive? Do you know of
    > comparable packages for Python?


    There are many graphing packages for python designed for many kinds of work.
    It should be pretty easy to find one that suits your purpose and use that.

    >
    >
    > I think that's it for now. Thank you for taking the time to read my
    > post and many thanks in advance to anyone who would be so kind as to reply.
    > (direct response to ej at wellkeeper dot com greatly appreciated).
    >
    > -ej


    Overall many people consider zope overkill for most web problems and they are
    probably right. It is a huge complex beast but it is also very good at
    solving large problems. It has a very flexible security model built into it,
    your code runs inside a sandbox unless specifically exempted, there are a lot
    of products designed to work with it and a lot of information on using it.

    I have no problem recommending zope over php and from what I have read of the
    twisted docs for woven I would recommend that over php also. Since python is
    not designed as a "web" language I find that overall it has been pretty easy
    to build larger solutions since a website is pretty much just a regular app
    with an html front end and you can use all the wide ranging features that
    python offers such as simpler to read code which makes maintainence easier.
    You also gain access to the large library of code available in the form of
    stuff like the python imaging library, reportlab, numpy etc.
     
    kosh, Feb 28, 2004
    #18
  19. Erik Johnson

    Bob Ippolito Guest

    On 2004-02-27 23:00:44 -0500, (Cameron Laird) said:

    > In article <>,
    > Erik Johnson <> wrote:
    > .
    > .
    > .
    >> some probably not. To those that have used PHP: what am I potentially losing
    >> that Python really can't replace?

    > .
    > .
    > .
    > The first thing that comes to my mind is the panoply of
    > data-management bindings PHP builds in. Those who need
    > to work with a variety of hosting providers like the
    > comfort of being able to count on the availability of
    > their favorite DBMS.


    Yes, PHP is widely available and easy to find cheap hosting for.
    Another additional 'benefit' is that PHP programmers are a dime a dozen
    (though you do get what you pay for). However, I can't imagine that
    you could make a good living developing software for companies who
    can't afford proper hosting, and I've never seen a project get done
    properly when you throw a bunch of low quality developers at it.
    Python is a LITTLE less esoteric than say, lisp or scheme, so the
    argument that it's going to be hard to find good Python programmers to
    maintain your software isn't a very good one either.

    All that said, PHP is a good language for a beginner. Lots of books
    are available that approach the subject from just about any angle, it
    is trivial to setup (you don't have to, you find some $5/mo provider to
    do it for you, or you buy OS X,), and is so underfeatured that you
    couldn't possibly be frightened by its syntax if it is one of the first
    few languages you've seen. That doesn't mean it's a good language to
    get real things done with though.

    Python has its share of problems too, but they typically only surface
    if you're not experienced enough (installing packages, finding
    packages, learning new APIs, etc.), or if you're TOO experienced
    (frustrated about the GIL, lack of multistate, no
    macro-like-facilities, standard distribution isn't stackless, little
    support for async programming, etc). Python evolves pretty quickly
    though, and we're attacking most of these problems at both ends (I'm
    personally working on packaging/distribution related matters, and
    stackless).

    -bob
     
    Bob Ippolito, Feb 28, 2004
    #19
  20. Erik Johnson

    Ville Vainio Guest

    >>>>> "Simon" == simo <> writes:

    Simon> Here's how I see it (I'm a Web Developer by trade): PHP -
    Simon> excellent database integration, if you don't want to have
    Simon> to use a Java application server for database work, go with
    Simon> PHP. Also nice templating system which even the Dreamweaver

    So, how do Python's DB modules fall short of those of PHP? If they
    indeed do, what should module developers do to fix this gap?

    I'm so very tired of the argument that because language X specializes
    in doing Q, it must be better than language Y (which is not
    specialized for any particular task) for doing Q:

    "Perl is only good for doing regexps, therefore it must be better than
    Python for doing regexps"

    "PHP is only good for doing DB connectivity /Web templating, therefore
    it must be better than Python for doing them"

    That just isn't logical.

    Simon> Perl - bloody fast, if you're doing lots of text
    Simon> processing/regex (e.g. XML parsing) then Perl is it,
    Simon> probably best for sysadmin tasks too. We use this for large

    This is another argument I can't understand. If perl crunches your log
    file in 3 minutes and Python takes 4 (but the script remains readable
    and maintainable), Python would still be my choice. And regexps for
    XML parsing don't always work anyway.

    Simon> The moral of the story is don't get locked into one
    Simon> technology, use the best tools for the job - especially if
    Simon> you happen to know them all! ;o)

    Often Python is the best tool for all the jobs there is to do. People
    just fail to see that because, driven by prejudice, they opt for the
    tool that can *only* do whatever the job is at the moment. That might
    have been sensible 15 years ago, but the software landscape has
    changed since.

    --
    Ville Vainio http://tinyurl.com/2prnb
     
    Ville Vainio, Feb 28, 2004
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cameron Laird
    Replies:
    3
    Views:
    387
    Giles Brown
    Mar 3, 2004
  2. Ted Zeng
    Replies:
    4
    Views:
    551
    Tim Arnold
    Oct 3, 2006
  3. pistacchio

    PHP + TinyButStrong Python replacement

    pistacchio, May 7, 2008, in forum: Python
    Replies:
    12
    Views:
    691
    Bruno Desthuilliers
    May 9, 2008
  4. Rajive Narain
    Replies:
    0
    Views:
    2,010
    Rajive Narain
    Sep 18, 2009
  5. Cameron Laird
    Replies:
    3
    Views:
    108
    Giles Brown
    Mar 3, 2004
Loading...

Share This Page