473,416 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Python as replacement for PHP?

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
Jul 17 '05 #1
28 4564
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.
Jul 17 '05 #2
With total disregard for any kind of safety measures "Erik
Johnson" <ej**************@dot.com> 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/
Jul 17 '05 #3
"Erik Johnson" <ej**************@dot.com> wrote in message
news:40******@news.zianet.com...
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
Jul 17 '05 #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

Jul 17 '05 #5
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
Jul 17 '05 #6
On Fri, 27 Feb 2004 13:50:09 -0700,
Erik Johnson <ej**************@dot.com> 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
Jul 17 '05 #7
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)
Jul 17 '05 #8
> 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
Jul 17 '05 #9
In article <30**************************@posting.google.com >,
simo <si************@yahoo.co.uk> wrote:
Jul 17 '05 #10
In article <40******@news.zianet.com>,
Erik Johnson <ej**************@dot.com> wrote:
Jul 17 '05 #11
>>>>> "Simon" == simo <si************@yahoo.co.uk> 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
Jul 17 '05 #12
Bart Nessux 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. (snip)
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:

(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.
(snip)
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.


(snip)

Bart, could you please back your (strong) assertions with at least one
argument ?

AFAIK, there is a whole lot of python tools for web developpement, and I
don't really see any evidence that one of the two languages is more or
less suited to this kind of task.

The only points I see in favor of PHP are :
- it's a de facto standard, widely used, widely available, and well
established
- there may be some specific libs not (currently) available in Python.

Bruno

Jul 17 '05 #13
> Bart, could you please back your (strong) assertions with at least one
argument ?

AFAIK, there is a whole lot of python tools for web developpement
The OP was comparing Python to PHP, not ZOPE to PHP. PHP by itself is a
natural Web programming language, Python is not. Google for dynamic DB
driven programming tools... how may PHP returns vs Python returns are
there?
The only points I see in favor of PHP are :
- it's a de facto standard, widely used, widely available, and well
established


That's exactly right. That's my point. I meant nothing more.
Jul 17 '05 #14
Erik Johnson wrote:

CAUTION: I'm replying as a non-Python programmer.
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.
You can do client-side apps in PHP too. Pass the -q option to the CGI
version or just use the CLI version.
GUI - PHP-GTK
Sockets - The socket extension or fsockopen() to treat it as a regular file.
3) Python's interactive interpreter makes it easy to try things out.
? Like the -r option?
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).
In PHP, all these things are essentially arrays and that works fine.
Even the PHP developers say that classes are just syntactic sugar for
associative arrays (that'll change in PHP 5, though). So PHP is
procedural; there's nothing wrong with that.


Not to sound like I hate everything which isn't PHP. It's just that PHP
does have a wide range of functionality and is moving toward
command-line/administration capabilities, and is quite easy to learn if
you know other C-like languages. But if you think that Python better
serves your purpose, then you should use it. Surely, it would be
possible to write a strtotime() implementation in Python; someone may
have already done so.

Jul 17 '05 #15
In article <du*************@amadeus.cc.tut.fi>,
Ville Vainio <vi***@spammers.com> wrote:

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.


and will change again before you're ready :-(
Use whatever you are happy with that does the job,
just do it so well that the next guy in your position
isn't tempted to rewrite it in his favorite language...
Jul 17 '05 #16
CountScubula schrieb:
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


I don't think so. It seems Python was written as a rapid development
language without a specific application range. That's an advantage
because you can get a lot of different jobs done very well. That's
a disadvantage because there's no no-brainer like "Python is for ...".

A family of marketing phrases comes into mind:

- Python is NOT for device drivers.
- Writing a device driver? Beware of Python!
- OS kernels? Don't even think of Python!
....

:)

Mit freundlichen Gruessen,

Peter Maas

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail pe********@mplusr.de
-------------------------------------------------------------------
Jul 17 '05 #17
Bart Nessux <ba*********@hotmail.com> 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. PHP claims to be
a general-purpose language, but I do not know anyone who uses it for
anything other than dynamic Web programming.
Like everyone else who has replied, I seriously question how much
experience you have with the multitude of Python web environments
available. As an objective, point-by-point look at your specific
example of somewhere PHP is strong, here's my reply:

[PS: I still use PHP regularly, albeit only for quick unimportant
hacks that won't exist in 6 months]
- Nearly all the PHP code I have seen (including various large web
sites) fails to handle error conditions, and will run amok given a
down DB server, bad filesystem permissions, or bad inputs. I have had
personal experience, on more than one occasion, of an error condition
in someone else's PHP code causing a large amount of damage to a
dataset.

- The equivalent Python code will almost never do that. Thanks to the
religious throwing of exceptions, well written standard libraries, DB
adaptors, and so on, the worst Python code has a MUCH better chance of
getting stopped in it's tracks just as a fault occurs.

py> open("/tmp/foo","w").write(123)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: argument 1 must be string or read-only character buffer,
not int
[22:15:14] [cape:4:dw]$ php4 <<e <? fwrite(fopen('foo','w'), 123); ?>
e

[22:15:16] [cape:5:dw]$ cat /tmp/foo
[22:15:17] [cape:6:dw]$

Can you tell me exactly what the PHP fwrite function did when I passed
it an integer? Can you tell me how many PHP programmers test
"(strlen($to_write) == fwrite($fp, $to_write))"?
- In the specific instance of database connectivity, Python is far
superior, in terms of intuitiveness, security, safety, and so on.
Python database APIs are built in a way that protects you by default.

- PHP provides no intuitive default support for many common DB
operations. Compare the following messes:

py> l = MySQLdb.connect()
py> c = l.cursor()
py> user_input = "%t%"
py> match_count = c.execute("SHOW DATABASES LIKE %s", ( user_input
))
py> print match_count, "matches:", [ x for x, in c ]
1 matches: ['test']
<? $s = mysql_connect();
$user_input = "%t%";
$query_sql = sprintf("SHOW DATABASES LIKE \"%s\"",
mysql_real_escape_string($user_input, $s));
$query = mysql_query($query_sql, $s);
$matches = array();
while ($row = mysql_fetch_array($query, MYSQL_NUM)) $matches[]=
$row[0];
echo sizeof($matches), " matches: ", var_export($matches, true);
Tell me, of these two popular examples of bad code in both languages,
which is the more intuitive to read, which is the more elegant to keep
secure, and which would you prefer to be reading, and modifying in 18
months time? [In this case, which was the quicker to create? The
Python example. The PHP counterpart has a syntax error somewhere, I
care not where.]

How many different ways can you dream up the same functionality in the
PHP example? (mysql_escape_string, <random_db_api>, etc.)

How likely is it that the developer you hire to take over development
of either snippet of code will understand the concept behind it? I
can't even think of another way of doing database query in Python,
without using the low-level interfaces, which is just insane.

We could bring the PHP ADODB, or many of the other numerous PHP APIs
for DB connectivity into the picture, but which of these are the
obvious choice, and officially endorsed?

How easy is it to improve on both these examples to add proper error
handling? Again, Python wins hands down for elegance, conciseness, and
obviousness.
- Python has a religious following of thousands, many of whom found
freedom through it's restraint, unified path, and downright beauty.
The result is a long tradition of structured, well written code.
Python has roots in academia, and started life with a defined purpose,
and a BDFL who knew what he was doing.

- PHP, "the web designer's ideal first language", started out life as
"a collection of perl scripts" (that says it all really), then ported
to C, then hacked and added to until it was the great swiss army
monolith that it is today. PHP has never had a clear, publically
documented development path, or indeed any form of structure or
organisation, past the menu system of PHP.net

PHP developers tend to have started life using Dreamweaver, happy to
accept the first solution to a problem that comes their way, and care
little about technical merit. Every person (including at the time,
myself) who I know that uses, or used PHP, did so because it allowed
them to make things look beautiful and dynamic very quickly.
- Python gurus, when asked how to make something work, will often
appear nasty and horrible, telling you you're doing entirely the wrong
thing and you should go back to the drawing board. Much like the hot
sting from a smack of a father's hand, this is good, not bad. It is
there to direct and discipline you, and improve the way you think.

- PHP gurus tend to be experienced web developers, they'll be able to
look flash and give you an answer on the spot, but that answer will
only further lead to the demise of any structure your coding ever had.

- Python tends to be slow, but slow compared to what? The laptop I
type this message on has a 2ghz processor. It cost less than £1000. It
is the cheapest laptop money can buy in the UK. I run Python scripts
on multi-gigabyte datasets on a daily basis on this machine. I have
never considered the scripts to be 'slow'.

- PHP is very light on CPU, memory, and so on. I earn a modest amount
for a 20 year old, even by Northern Ireland standards. I can't see how
I would ever need to resort to PHP because I couldn't afford the
hardware to run a complex Python-based site intended for viewing by
thousands.
Personally, I find the average PHP codebase to be akin to a television
station such as MTV: well presented, streamlined, professional
looking, but in terms of content, nothing but meaningless, mindless
shite. On the other hand, reading certain Python code is more like
reading a beautifully typeset hardback novel: black and white - ugly
to some, but functional, educational, structured, meaningful, etc,
etc.

What interests you more - earning money through thoughtless,
effortlessly produced rant-syntax that no-one will ever want to look
at again, or the daily challenge to produce something that will
perfectly fulfill it's intended function, at the cost of a little
time, a little brainpower, and a little discipline.

I could go on, but I think these points alone are the main reasons I
use Python. At the cost only of speed, it protects me, teaches me,
profits me, and inspires me to continue being the professional geek
that I am. :)
David.
Jul 17 '05 #18
"David M. Wilson" <dw***********@botanicus.net> wrote in message
news:99**************************@posting.google.c om...
Bart Nessux <ba*********@hotmail.com> 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. PHP claims to be
a general-purpose language, but I do not know anyone who uses it for
anything other than dynamic Web programming.


Like everyone else who has replied, I seriously question how much
experience you have with the multitude of Python web environments
available. As an objective, point-by-point look at your specific
example of somewhere PHP is strong, here's my reply:

[PS: I still use PHP regularly, albeit only for quick unimportant
hacks that won't exist in 6 months]


< a lot of brilliant points snipped />

ROFLMAO!

Wohoo!

Thisone is going to draw some heat, David!

(Not that I don't agree with you, though...
Python is probably the most beautiful
scripting language I've ever used).

--
Dag.
Jul 17 '05 #19
[Well, this time I have decided to troll -- all because of prolong
irritating ignorant posts/crossposts. And, this is intentional
crosspost.]

dw***********@botanicus.net (David M. Wilson) wrote in message news:<99**************************@posting.google. com>...
Bart Nessux <ba*********@hotmail.com> 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. PHP claims to be
a general-purpose language, but I do not know anyone who uses it for
anything other than dynamic Web programming.
Like everyone else who has replied, I seriously question how much
experience you have with the multitude of Python web environments
available. As an objective, point-by-point look at your specific
example of somewhere PHP is strong, here's my reply:

[PS: I still use PHP regularly, albeit only for quick unimportant
hacks that won't exist in 6 months]


So.. you don't have any important works :-/
- Nearly all the PHP code I have seen (including various large web
sites) fails to handle error conditions, and will run amok given a
down DB server, bad filesystem permissions, or bad inputs. I have had
personal experience, on more than one occasion, of an error condition
in someone else's PHP code causing a large amount of damage to a
dataset.
Good news. Well done PHP!
- The equivalent Python code will almost never do that. Thanks to the
religious throwing of exceptions, well written standard libraries, DB
adaptors, and so on, the worst Python code has a MUCH better chance of
getting stopped in it's tracks just as a fault occurs.

py> open("/tmp/foo","w").write(123)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: argument 1 must be string or read-only character buffer,
not int
[22:15:14] [cape:4:dw]$ php4 <<e
> <? fwrite(fopen('foo','w'), 123); ?>
> e [22:15:16] [cape:5:dw]$ cat /tmp/foo
[22:15:17] [cape:6:dw]$

Can you tell me exactly what the PHP fwrite function did when I passed
it an integer? Can you tell me how many PHP programmers test
"(strlen($to_write) == fwrite($fp, $to_write))"?

Ok...understand. idiot-proof?
- In the specific instance of database connectivity, Python is far
superior, in terms of intuitiveness, security, safety, and so on.
Python database APIs are built in a way that protects you by default.
Perhaps, idiots' own language?
- PHP provides no intuitive default support for many common DB
operations. Compare the following messes:

py> l = MySQLdb.connect()
py> c = l.cursor()
py> user_input = "%t%"
py> match_count = c.execute("SHOW DATABASES LIKE %s", ( user_input
))
py> print match_count, "matches:", [ x for x, in c ]
1 matches: ['test']
<? $s = mysql_connect();
$user_input = "%t%";
$query_sql = sprintf("SHOW DATABASES LIKE \"%s\"",
mysql_real_escape_string($user_input, $s));
$query = mysql_query($query_sql, $s);
$matches = array();
while ($row = mysql_fetch_array($query, MYSQL_NUM)) $matches[]=
$row[0];
echo sizeof($matches), " matches: ", var_export($matches, true);
Tell me, of these two popular examples of bad code in both languages,
which is the more intuitive to read, which is the more elegant to keep
secure, and which would you prefer to be reading, and modifying in 18
months time? [In this case, which was the quicker to create? The
Python example. The PHP counterpart has a syntax error somewhere, I
care not where.]

How many different ways can you dream up the same functionality in the
PHP example? (mysql_escape_string, <random_db_api>, etc.)

How likely is it that the developer you hire to take over development
of either snippet of code will understand the concept behind it? I
can't even think of another way of doing database query in Python,
without using the low-level interfaces, which is just insane.

We could bring the PHP ADODB, or many of the other numerous PHP APIs
for DB connectivity into the picture, but which of these are the
obvious choice, and officially endorsed?

How easy is it to improve on both these examples to add proper error
handling? Again, Python wins hands down for elegance, conciseness, and
obviousness.
Yes, agreed. Idiots' language.
- Python has a religious following of thousands, many of whom found
freedom through it's restraint, unified path, and downright beauty.
The result is a long tradition of structured, well written code.
Python has roots in academia, and started life with a defined purpose,
and a BDFL who knew what he was doing.

- PHP, "the web designer's ideal first language", started out life as
"a collection of perl scripts" (that says it all really), then ported
to C, then hacked and added to until it was the great swiss army
monolith that it is today. PHP has never had a clear, publically
documented development path, or indeed any form of structure or
organisation, past the menu system of PHP.net
LOL! Joke of the millennium.
PHP developers tend to have started life using Dreamweaver, happy to
accept the first solution to a problem that comes their way, and care
little about technical merit. Every person (including at the time,
myself) who I know that uses, or used PHP, did so because it allowed
them to make things look beautiful and dynamic very quickly.
Yet another good joke.
- Python gurus, when asked how to make something work, will often
appear nasty and horrible, telling you you're doing entirely the wrong
thing and you should go back to the drawing board. Much like the hot
sting from a smack of a father's hand, this is good, not bad. It is
there to direct and discipline you, and improve the way you think.

- PHP gurus tend to be experienced web developers, they'll be able to
look flash and give you an answer on the spot, but that answer will
only further lead to the demise of any structure your coding ever had.
Huh??
- Python tends to be slow, but slow compared to what? The laptop I
type this message on has a 2ghz processor. It cost less than £1000. It
is the cheapest laptop money can buy in the UK. I run Python scripts
on multi-gigabyte datasets on a daily basis on this machine. I have
never considered the scripts to be 'slow'.

- PHP is very light on CPU, memory, and so on. I earn a modest amount
for a 20 year old, even by Northern Ireland standards. I can't see how
I would ever need to resort to PHP because I couldn't afford the
hardware to run a complex Python-based site intended for viewing by
thousands.
Personally, I find the average PHP codebase to be akin to a television
station such as MTV: well presented, streamlined, professional
looking, but in terms of content, nothing but meaningless, mindless
shite. On the other hand, reading certain Python code is more like
reading a beautifully typeset hardback novel: black and white - ugly
to some, but functional, educational, structured, meaningful, etc,
etc.

What interests you more - earning money through thoughtless,
effortlessly produced rant-syntax that no-one will ever want to look
at again, or the daily challenge to produce something that will
perfectly fulfill it's intended function, at the cost of a little
time, a little brainpower, and a little discipline.

I could go on, but I think these points alone are the main reasons I
use Python. At the cost only of speed, it protects me, teaches me,
profits me, and inspires me to continue being the professional geek
that I am. :)


comp.lang.php is not the right place for you to show your
stupidity. You should consider stripping headers as many other PHP
ignorants (<http://groups.google.com/groups?threadm=403fa54b%40news.zianet.com>)
did before throwing your thoughts.

HTH. HAND.

--
From comp.lang.php
"Success is not what you achieve, but it is what you die for"
If you live in USA, please support John Edwards.
Email: rrjanbiah-at-Y!com
Jul 17 '05 #20
>>>>> "R" == R Rajesh Jeba Anbiah <ng**********@rediffmail.com> writes:

R> [Well, this time I have decided to troll -- all because of

Ok, I get the drift.
Can you tell me exactly what the PHP fwrite function did when I
passed it an integer? Can you tell me how many PHP programmers
test "(strlen($to_write) == fwrite($fp, $to_write))"?

R> Ok...understand. idiot-proof?

So type safety means idiot-proofing? What do you gain by allowing
obvious errors to be silently ignored?

When a third-party library returns an object you didn't expect in
writing your code, you would surely want to know? I do.
- In the specific instance of database connectivity, Python is
far superior, in terms of intuitiveness, security, safety, and
so on. Python database APIs are built in a way that protects
you by default.
R> Perhaps, idiots' own language?

You still realize this is crossposted to c.l.py, right? Kindergarten
tactics don't erally work all that well here. Some observer of this
discussion might draw some conclusions about which one of the
languages is the "idiot's own language"...
How easy is it to improve on both these examples to add proper
error handling? Again, Python wins hands down for elegance,
conciseness, and obviousness.


R> Yes, agreed. Idiots' language.

Yes, elegance is indeed for idiots. True r0xx0r h4xxx0rz use PHP,
because it's so cryptic and looks cool because n00bs can't understand
it.

R> comp.lang.php is not the right place for you to show your
R> stupidity. You should consider stripping headers as many other

Neither is c.l.py. Actually, we have remarkably few idiots in c.l.py.

I don't know why I'm replying - your post kinda speaks for itself.

--
Ville Vainio http://tinyurl.com/2prnb
Jul 17 '05 #21
With total disregard for any kind of safety measures
dw***********@botanicus.net (David M. Wilson) leapt forth and
uttered:
- Python gurus, when asked how to make something work, will
often appear nasty and horrible, telling you you're doing
entirely the wrong thing and you should go back to the drawing
board. Much like the hot sting from a smack of a father's hand,
this is good, not bad. It is there to direct and discipline you,
and improve the way you think. - PHP gurus tend to be experienced web developers, they'll be
able to look flash and give you an answer on the spot, but that
answer will only further lead to the demise of any structure
your coding ever had.


So, by your logic Python developers tend to be self-important
assholes whereas PHP developers will give you an answer, but they
expect you to have enough knowledge to implement it correctly?

--
Phil Roberts | Dork Pretending To Be Hard | http://www.flatnet.net/
Jul 17 '05 #22
Ville Vainio <vi***@spammers.com> wrote in message news:<du*************@mozart.cc.tut.fi>...
>> "R" == R Rajesh Jeba Anbiah <ng**********@rediffmail.com> writes:
R> [Well, this time I have decided to troll -- all because of

Ok, I get the drift.
Mr.Ville Vainio, I really impressed by your detector and the way
you snip others' comments. Thanks.
>> Can you tell me exactly what the PHP fwrite function did when I
>> passed it an integer? Can you tell me how many PHP programmers
>> test "(strlen($to_write) == fwrite($fp, $to_write))"?

R> Ok...understand. idiot-proof?

So type safety means idiot-proofing? What do you gain by allowing
obvious errors to be silently ignored?

When a third-party library returns an object you didn't expect in
writing your code, you would surely want to know? I do.


If you do *programming* without knowing what to pass to a function
or what a function returns, you're a complete idiot as a idiot can be.
Moreover, if you take it as an argument against PHP, you're yet
another ignorant and obviously you don't have any rights to speak
about PHP nor anything.

>> - In the specific instance of database connectivity, Python is
>> far superior, in terms of intuitiveness, security, safety, and
>> so on. Python database APIs are built in a way that protects
>> you by default.
R> Perhaps, idiots' own language?

You still realize this is crossposted to c.l.py, right? Kindergarten
tactics don't erally work all that well here.


Huh?? So..here, where you stand??
Some observer of this
discussion might draw some conclusions about which one of the
languages is the "idiot's own language"...
Yes, people with functioning brain may already conculded that when
you posted your previous message itself.
>> How easy is it to improve on both these examples to add proper
>> error handling? Again, Python wins hands down for elegance,
>> conciseness, and obviousness.


R> Yes, agreed. Idiots' language.

Yes, elegance is indeed for idiots. True r0xx0r h4xxx0rz use PHP,
because it's so cryptic and looks cool because n00bs can't understand
it.


If you post these jottings to the PHP ignorants, they may even
build a statue for you. But, I guess, it is hard to get that kind of
ignorants.

R> comp.lang.php is not the right place for you to show your
R> stupidity. You should consider stripping headers as many other

Neither is c.l.py. Actually, we have remarkably few idiots in c.l.py.
No problem. I could see here itself
<http://groups.google.com/groups?threadm=403fa54b%40news.zianet.com>
I don't know why I'm replying - your post kinda speaks for itself.


Thanks Mr.Ville Vainio for sparing your time to provide brilliant
comments.

HTH. HAND.

--
From comp.lang.php
"I don't believe in the God who doesn't give me food, but shows me
heaven!"--Swami Vivekanandha
If you live in USA, please support John Edwards.
Email: rrjanbiah-at-Y!com
Jul 17 '05 #23
>>>>> "R" == R Rajesh Jeba Anbiah <ng**********@rediffmail.com> writes:

R> If you do *programming* without knowing what to pass to a
R> function or what a function returns, you're a complete idiot as
R> a idiot can be. Moreover, if you take it as an argument

Occasionally, in absence of static typing, you might accidentally call
a function using a return value of another function as an argument and
they are not compatible. W/ python you notice it immediately; with PHP
or Perl your program starts behaving weirdly (if you don't check
return values that is) and you can't pinpoint exactly what went
wrong. This is what makes people run to statically typed languages,
believing that all dynamic typing is shoddy like this.

R> against PHP, you're yet another ignorant and obviously you
R> don't have any rights to speak about PHP nor anything.

I wasn't really talking about PHP, but the approach you took to attack
the arguments of OP (arguments which I agree w/ BTW, but that's
another story).

R> Yes, people with functioning brain may already conculded that
R> when you posted your previous message itself.

Previous message? The one you were replying to was the first I posted
to this thread.
Neither is c.l.py. Actually, we have remarkably few idiots in
c.l.py.


R> No problem. I could see here itself
R> <http://groups.google.com/groups?threadm=403fa54b%40news.zianet.com>

Great.

--
Ville Vainio http://tinyurl.com/2prnb
Jul 17 '05 #24
Peter Maas <fp********@netscape.net> wrote in message news:<c2**********@swifty.westend.com>...
R. Rajesh Jeba Anbiah schrieb:
If you do *programming* without knowing what to pass to a
> function
or what a function returns, you're a complete idiot as a idiot can be.
Moreover, if you take it as an argument against PHP, you're yet
another ignorant and obviously you don't have any rights to speak
about PHP nor anything.
Excuse me ... Does the life of your children depend on a friendly.
reception of PHP?


Sorry, I couldn't understand what do you mean here (My first
language is Tamil)
I'm just searching a reason for your aggressiveness.
No need to embarrass yourself by researching; I've already said the
reason. Did you read the thread actually?
Never saw that in c.l.py.
Might be some problem with your news server. Perhaps you should
read the thread first
<http://groups.google.com/groups?threadm=403fa54b%40news.zianet.com>
Mit freundlichen Gruessen,


நட்புடன்

HAND.

--
From comp.lang.php
"I don't believe in the God who doesn't give me food, but shows me
heaven!"--Swami Vivekanandha
If you live in USA, please support John Edwards.
Email: rrjanbiah-at-Y!com
Jul 17 '05 #25
Ville Vainio <vi***@spammers.com> wrote in message news:<du*************@amadeus.cc.tut.fi>...
>> "R" == R Rajesh Jeba Anbiah <ng**********@rediffmail.com> writes:


R> If you do *programming* without knowing what to pass to a
R> function or what a function returns, you're a complete idiot as
R> a idiot can be. Moreover, if you take it as an argument

Occasionally, in absence of static typing, you might accidentally call
a function using a return value of another function as an argument and
they are not compatible. W/ python you notice it immediately; with PHP
or Perl your program starts behaving weirdly (if you don't check
return values that is) and you can't pinpoint exactly what went
wrong. This is what makes people run to statically typed languages,
believing that all dynamic typing is shoddy like this.

R> against PHP, you're yet another ignorant and obviously you
R> don't have any rights to speak about PHP nor anything.

I wasn't really talking about PHP, but the approach you took to attack
the arguments of OP (arguments which I agree w/ BTW, but that's
another story).

R> Yes, people with functioning brain may already conculded that
R> when you posted your previous message itself.

Previous message? The one you were replying to was the first I posted
to this thread.


Obviously, you should know what you're doing
(<http://groups.google.com/groups?threadm=403fa54b%40news.zianet.com>)
And, please find some time to learn about the error reporting or error
handling mechanism of the languages before throwing your comments.
(Hint: Your comments clearly shows your ignorance in one or more
languages)

HTH. HAND.

--
From comp.lang.php
"I don't believe in the God who doesn't give me food, but shows me
heaven!"--Swami Vivekanandha
If you live in USA, please support John Edwards.
Email: rrjanbiah-at-Y!com
Jul 17 '05 #26
R. Rajesh Jeba Anbiah wrote:

HTH. HAND.


Is this your signature or nickname, or does it perhaps mean something in
your native language (like "ciao", for example)? I assumed it was your
signature, but it doesn't resemble your name, so I thought it may mean
something else. Perhaps it's like those "geek codes" some people put in
their signatures?

bblackmoor
2004-03-07
Jul 17 '05 #27
I noticed that Message-ID: <c2*************@ID-97660.news.uni-berlin.de>
from Brandon Blackmoor contained the following:
HTH. HAND.


Is this your signature or nickname, or does it perhaps mean something in
your native language (like "ciao", for example)?


Hope This Helps. Have A Nice Day

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #28
Geoff Berrow wrote:
HTH. HAND.


Hope This Helps. Have A Nice Day


Wow. That's really lazy.

bblackmoor
2004-03-08
Jul 17 '05 #29

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

49
by: Ville Vainio | last post by:
I don't know if you have seen this before, but here goes: http://text.userlinux.com/white_paper.html There is a jab at Python, though, mentioning that Ruby is more "refined". -- Ville...
5
by: Vamsee Krishna Gomatam | last post by:
Hello, I'm having some problems understanding Regexps in Python. I want to replace "<google>PHRASE</google>" with "<a href=http://www.google.com/search?q=PHRASE>PHRASE</a>" in a block of text....
3
by: Vibha Tripathi | last post by:
Hi Folks, I put a Regular Expression question on this list a couple days ago. I would like to rephrase my question as below: In the Python re.sub(regex, replacement, subject)...
17
by: DanielJohnson | last post by:
how to use the combination function in python ? For example 9 choose 2 (written as 9C2) = 9!/7!*2!=36 Please help, I couldnt find the function through help.
40
by: walterbyrd | last post by:
I mean other than sysadmins, programmers, and web-site developers? I have heard of some DBAs who use a lot of python. I suppose some scientists. I think python is used in bioinformatics. I...
19
by: John Salerno | last post by:
Hey all. Just thought I'd ask a general question for my own interest. Every time I think of something I might do in Python, it usually involves creating a GUI interface, so I was wondering what kind...
4
by: Mensanator | last post by:
With the new functions added to itertools in Python 2.6, I can finally get rid of this monstrosity: def ooloop6(a, n, perm=True, repl=True): if (not repl) and (n>len(a)): return r0 = range(n)...
20
by: Mr.SpOOn | last post by:
Hi, I need a structure to represent a set of integers. I also need to perform on this set some basic set operations, such as adding or removing elements, joining with other sets and checking for...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.