Python vs PHP

Discussion in 'Python' started by Catalin, Jul 7, 2003.

  1. Catalin

    Catalin Guest

    Can Python replace PHP?
    Can I use a python program to make an interface to a mysql 4.X database?
    If that's possible where can I find a tutorial?
     
    Catalin, Jul 7, 2003
    #1
    1. Advertising

  2. Hi !

    PHP-5 let down MySql, for Sql-Lite (rumor ?)

    Python has good support for MySql AND Sql-Lite.

    @+

    Michel Claveau
     
    News M Claveau /Hamster-P, Jul 7, 2003
    #2
    1. Advertising

  3. Catalin

    Aahz Guest

    In article <>,
    Catalin <> wrote:
    >
    >Can Python replace PHP?
    >Can I use a python program to make an interface to a mysql 4.X database?


    The short answer is "yes" to both questions, but with a caveat: Python is
    a general-purpose programming language, where PHP is designed to write
    web applications. So it's not quite as simple/straightforward to use
    Python the same way you use PHP for plain web pages; conversely, if
    you've been running into difficulty with PHP in trying to write
    complicated program logic, you'll find Python a big help.
    --
    Aahz () <*> http://www.pythoncraft.com/

    "Not everything in life has a clue in front of it...." --JMS
     
    Aahz, Jul 7, 2003
    #3
  4. News M Claveau /Hamster-P wrote:
    > Hi !
    >
    > PHP-5 let down MySql, for Sql-Lite (rumor ?)


    PHP 5 won't come bundled with a default MySql lib, but anyone is still
    free to link against the official MySQL lib, one way or another...

    And yes, the default 'bundled-in' SQL lib should be Sql-lite.

    Bruno
     
    Bruno Desthuilliers, Jul 7, 2003
    #4
  5. Jaroslaw Zabiello, Jul 8, 2003
    #5
  6. Catalin

    Jp Calderone Guest

    On Tue, Jul 08, 2003 at 11:14:10AM +0200, Jaroslaw Zabiello wrote:
    > On Mon, 07 Jul 2003 13:47:00 +0300, Catalin
    > <> wrote:
    >
    > >Can Python replace PHP?

    >
    > Sure. Look at http://spyce.sourceforge.net
    >


    Lest the OP think Spyce is the only or even the preferred solution for web
    programming with Python:

    http://cherrypy.org/

    http://www.twistedmatrix.com/

    http://skunkweb.sf.net

    http://webware.sf.net

    http://zope.org

    http://www.mems-exchange.org/software/quixote/

    http://www.object-craft.com.au/projects/albatross

    http://jonpy.sf.net

    http://jotweb.tummy.com/

    And let's not forget plain old CGI and mod_python.

    Jp

    --
    "There is no reason for any individual to have a computer in their
    home."
    -- Ken Olson, President of DEC, World Future Society
    Convention, 1977
     
    Jp Calderone, Jul 8, 2003
    #6
  7. Catalin

    Afanasiy Guest

    On Mon, 07 Jul 2003 13:47:00 +0300, Catalin <>
    wrote:

    >Can Python replace PHP?
    >Can I use a python program to make an interface to a mysql 4.X database?
    >If that's possible where can I find a tutorial?
    >


    I recommend Spyce, Webware, or Quixote depending on your requirements,
    but Draco, SkunkWeb, RoadKill are worth looking into as well. Spyce is
    really the best (for PHP-ness) in my opinion, after you actually get past
    the fact that it supports your old fashioned notion of what embedded
    delimiters should look like, as well as a new CTS-friendly alternative.

    Spyce is the closest thing to PHP, but also provides some features PHP
    does not. However, I think you will find some people, like myself, who are
    still unable to make the switch from PHP to Python for web development,
    because of a lot of little things. These people know Python is better and
    may even know their non-web PHP applications are hell compared to their
    Python re-implementations. However, they still use PHP for web development
    and feel they have to. They may have even written out all the requirements
    and received vague responses to them.

    Python web development is fragmented. Mod_python CVS now contains the work
    of what used to be mod_psp by Sterling Hughes, a PHP warlord, I'm sure
    he'll reply. This possibly soon to be official 'PSP' is not much in my
    opinion and should probably not be folded into mod_python. Others agree:

    http://www.modpython.org/pipermail/mod_python/2003-June/003200.html

    Another big problem with Python web development is the lack of good shared
    hosting support. Primarily the lack of anything resembling PHP's safe
    mode. Mod_python has no equivalent of this safe mode, but Apache 2's
    'Perchild MPM' is supposed deprecates this need. However, this still
    requires an httpd.conf edit and a restart of Apache for every user added,
    very annoying, especially to a shared hosting service.

    http://apache.slashdot.org/apache/02/12/02/1346206.shtml?tid=
    http://httpd.apache.org/docs-2.0/mod/perchild.html
    http://www.modpython.org/pipermail/mod_python/2001-November/001705.html

    A couple other slight issues :

    * catch-all error handling not as flexible or non-existent
    * no equivalent to php_value auto_prepend_file "_header.php"
    * no equivalent to php_value auto_append_file "_footer.php"
    * not as intelligent form value handling
    * white space sensitivity is a unique problem when embedding

    The best options for me are currently :

    * use PHP
    * use Spyce
    * fork Spyce (creating more fragmentation)
    * embed python straight into my favorite platform (quite funny)
    * write my own mod_python-based platform (more fragmentation)
    * find the holy grail (i must have missed it)

    I've been handling this dilemma for months. I've even benchmarked quite a
    few possible solutions, with pleasing results in those which I thought
    were well done, and pleasing results for Python over PHP in general.

    -AB
     
    Afanasiy, Jul 8, 2003
    #7
  8. Catalin

    Jon Ribbens Guest

    In article <>, Afanasiy wrote:
    > A couple other slight issues :
    >
    > * catch-all error handling not as flexible or non-existent
    > * no equivalent to php_value auto_prepend_file "_header.php"
    > * no equivalent to php_value auto_append_file "_footer.php"
    > * not as intelligent form value handling
    > * white space sensitivity is a unique problem when embedding


    Try jonpy (http://jonpy.sf.net/), it solves all of the above.
    Also you may find FastCGI (which jonpy supports) helps with your
    "safe mode" problem, although it might require a bit of hackery.
     
    Jon Ribbens, Jul 8, 2003
    #8
  9. Catalin

    Afanasiy Guest

    On Tue, 08 Jul 2003 15:56:58 GMT, Afanasiy <> wrote:

    >On Mon, 07 Jul 2003 13:47:00 +0300, Catalin <>
    >wrote:


    >A couple other slight issues :
    >
    >* catch-all error handling not as flexible or non-existent
    >* no equivalent to php_value auto_prepend_file "_header.php"
    >* no equivalent to php_value auto_append_file "_footer.php"
    >* not as intelligent form value handling
    >* white space sensitivity is a unique problem when embedding


    I think I should add import, pythonpath and module caching to this list.
    These are much more annoying than PHP's inclusion mechanisms. I am even
    annoyed in non-web applications by them quite often, but not necessarily
    all at the same time.

    Also add to the list, the need for PyChecker. You must run PyChecker
    to discover errors which would occur on a section of logic being hit
    which contained a silly typographical error. PHP would discover these
    without them being hit, when you were developing the page.

    Python is more beautiful and more powerful, but for this purpose I
    consider the current implementations still lacking compared to PHP.
    So much so that I am unable to bring myself to write new PHP, but
    unable to continue using Python until I find the perfect implementation.

    -AB
     
    Afanasiy, Jul 8, 2003
    #9
  10. Catalin

    Afanasiy Guest

    On 8 Jul 2003 16:02:48 GMT, Jon Ribbens <>
    wrote:

    >In article <>, Afanasiy wrote:
    >> A couple other slight issues :
    >>
    >> * catch-all error handling not as flexible or non-existent
    >> * no equivalent to php_value auto_prepend_file "_header.php"
    >> * no equivalent to php_value auto_append_file "_footer.php"
    >> * not as intelligent form value handling
    >> * white space sensitivity is a unique problem when embedding

    >
    >Try jonpy (http://jonpy.sf.net/), it solves all of the above.
    >Also you may find FastCGI (which jonpy supports) helps with your
    >"safe mode" problem, although it might require a bit of hackery.


    No, CGI is not an option and I tried jonpy. I kept my notes about it...
     
    Afanasiy, Jul 8, 2003
    #10
  11. Catalin

    Jon Ribbens Guest

    In article <>, Afanasiy wrote:
    > CGI, FastCGI, SCGI are not faster than mod_python in my experience and
    > straightforward benchmark.


    In the case of CGI, yes of course. In the case of FastCGI, your
    experience contradicts my own.

    > That's all I can really say about it. CGI is not an option for me.


    I don't understand why you keep saying "CGI is not an option" when
    nobody has suggested that you use it.
     
    Jon Ribbens, Jul 8, 2003
    #11
  12. Catalin

    Afanasiy Guest

    On 8 Jul 2003 17:59:12 GMT, Jon Ribbens <>
    wrote:


    >I don't understand why you keep saying "CGI is not an option" when
    >nobody has suggested that you use it.


    Ok
     
    Afanasiy, Jul 9, 2003
    #12
  13. On 8 Jul 2003 17:59:12 GMT,
    Jon Ribbens <> wrote:
    > I don't understand why you keep saying "CGI is not an option" when
    > nobody has suggested that you use it.


    Jon, there's no point in debating Afanasiy about CGI. He's convinced
    packages for Python web programming support are inadequate (*all* of them),
    is unable to explain what the problem is or what his requirements are, and
    doesn't seem to really understand the subject (e.g. thinking FastCGI is
    basically the same as regular CGI). Ignoring him is the best course.

    --amk
     
    A.M. Kuchling, Jul 9, 2003
    #13
  14. Catalin

    Afanasiy Guest

    On Tue, 08 Jul 2003 20:46:53 -0500, "A.M. Kuchling" <> wrote:

    >On 8 Jul 2003 17:59:12 GMT,
    > Jon Ribbens <> wrote:
    >> I don't understand why you keep saying "CGI is not an option" when
    >> nobody has suggested that you use it.

    >
    >Jon, there's no point in debating Afanasiy about CGI. He's convinced
    >packages for Python web programming support are inadequate (*all* of them),
    >is unable to explain what the problem is or what his requirements are, and
    >doesn't seem to really understand the subject (e.g. thinking FastCGI is
    >basically the same as regular CGI). Ignoring him is the best course.


    Read.
     
    Afanasiy, Jul 9, 2003
    #14
  15. Catalin

    Jon Ribbens Guest

    In article <>, A.M. Kuchling wrote:
    > Jon, there's no point in debating Afanasiy about CGI. He's convinced
    > packages for Python web programming support are inadequate (*all* of them),
    > is unable to explain what the problem is or what his requirements are, and
    > doesn't seem to really understand the subject (e.g. thinking FastCGI is
    > basically the same as regular CGI). Ignoring him is the best course.


    Oh, ok, ta ;-)
     
    Jon Ribbens, Jul 9, 2003
    #15
  16. Re: Sample Web application (Re: Python vs PHP)

    A.M. Kuchling wrote:
    > At PyCon, it was generally agreed at the Web programming BoF that the
    > authors of the various Python frameworks should all implement the same
    > example application so that potential users can compare the resulting
    > code. Nothing much has been done on this front since then; we should
    > get things moving again by figuring out what the example application
    > should be. The Java Pet Store was suggested, but it was pointed out
    > that it's a very large application, requiring too much effort for an
    > author to do in their spare time.


    Ian Bicking did something like this with
    http://colorstudy.com/docs/shootout.html with a Wiki as the example
    application. If there is interest, I would volunteer to copy this into the
    Wiki so that it can be more easily extended. I already got Ian's
    permissionto do so, but was so far too lazy for it.

    > Let's think about the requirements for an example application:
    >
    > * Should be implementable in a few evenings
    > * Should exercise a reasonable set of features.
    > * HTML generation (duh!)
    > * Accepting a form
    > * Returning non-HTML files (generating a GIF, say)
    > * Sessions


    * access control


    I suggest using
    http://www.python.org/cgi-bin/moinmoin/WebProgrammingShootOut as the entry
    point for the specification of the application.

    Daniel
     
    Daniel Dittmar, Jul 9, 2003
    #16
  17. Catalin

    Ian Bicking Guest

    Re: Sample Web application (Re: Python vs PHP)

    On Wed, 2003-07-09 at 10:26, Daniel Dittmar wrote:
    > Ian Bicking did something like this with
    > http://colorstudy.com/docs/shootout.html with a Wiki as the example
    > application. If there is interest, I would volunteer to copy this into the
    > Wiki so that it can be more easily extended. I already got Ian's
    > permissionto do so, but was so far too lazy for it.


    It might be preferable to do this in CVS somewhere -- it would handle
    the source files better, and most of the commentary can go in comments.

    One of the big problems I also had was installation. Many of the
    frameworks require non-trivial Apache configuration, which hinders
    experimentation. Actually solving this is significant work, though --
    but also something which very much deserves solving.

    A SourceForge (or equivalent) project might be a good place to start.

    Ian
     
    Ian Bicking, Jul 9, 2003
    #17
  18. Re: Sample Web application (Re: Python vs PHP)

    "A.M. Kuchling" <> wrote in message news:

    > The Java Pet Store was suggested, but it was pointed out that it's a very
    > large application, requiring too much effort for an author to do in their
    > spare time.


    But you can see the difference only in larger application. Not
    everything scales good when programming in the large is necessary. I
    never found that simple benchmarks really helps.


    > I think I like the store best, because the first three applications are
    > all text-oriented, and the content manager doesn't do much beyond spitting back


    Yes, me too. It should be something that is usefull for comparison in
    larger commercial applications. And it should have test generators to
    check the system under heavy system load.
     
    Lothar Scholz, Jul 9, 2003
    #18
  19. Catalin

    Aahz Guest

    Re: Sample Web application (Re: Python vs PHP)

    In article <>,
    A.M. Kuchling <> wrote:
    >
    >That reminds me: there was also a proposal to revive the Web-SIG. Ian,
    >anything moving on this front? (My offer to host a list still stands.)


    I'd suggest putting it on python.org, so that anyone who who looks at
    the mailing lists will find it.
    --
    Aahz () <*> http://www.pythoncraft.com/

    "Not everything in life has a clue in front of it...." --JMS
     
    Aahz, Jul 9, 2003
    #19
  20. Catalin

    Paul Rubin Guest

    Re: Sample Web application (Re: Python vs PHP)

    "A.M. Kuchling" <> writes:
    > The Java Pet Store was suggested, but it was pointed out that it's a very
    > large application, requiring too much effort for an author to do in their
    > spare time.


    Heh, the point of doing it in Python is it should take much less time
    than doing it in Java :).

    > * Should be implementable in a few evenings


    Good

    > * Should exercise a reasonable set of features.
    > * HTML generation (duh!)
    > * Accepting a form


    Accepting a very long form (i.e. megabytes of POST data)

    > * Returning non-HTML files (generating a GIF, say)
    > * Sessions
    > * Uploading a file
    > * RDBMS access? (That's more a function of the DB-API module you're
    > using, but a framework might provide support for pooling
    > connections or something similar.)


    Yes, this should be included, lack of a standard DB API module is a
    serious Python deficiency and any DB-using app needs to work around
    the deficiency somehow.

    > * Other suggestions?
    >
    > Possibilities:
    > * A Wiki?
    > * A multiple-user weblog?
    > * A Slashdot-like discussion board?
    > * A simple content manager -- upload files, set permissions on them,
    > control access to them, and download them again.
    > * A simple browse-a-catalog-and-buy-things store?
    > * Other suggestions?


    Webmail client
     
    Paul Rubin, Jul 9, 2003
    #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. Ted Zeng
    Replies:
    4
    Views:
    572
    Tim Arnold
    Oct 3, 2006
  2. Ted Zeng
    Replies:
    0
    Views:
    686
    Ted Zeng
    Oct 13, 2006
  3. torque63
    Replies:
    0
    Views:
    666
    torque63
    Jan 1, 2009
  4. raviraj joshi
    Replies:
    0
    Views:
    360
    raviraj joshi
    Jul 4, 2009
  5. Rajive Narain
    Replies:
    0
    Views:
    2,091
    Rajive Narain
    Sep 18, 2009
Loading...

Share This Page