Dijkstra on Python
James J. Besemer
jb at cascade-sys.com
Tue Aug 13 07:49:01 EDT 2002
Roy Smith wrote:
> I agree 105% that having an alternative form of the "if" statement in
> perl is utterly brain-dead. It's different for the sake of being
> different, and adds no value that I can see.
I think the mistake was in originally always requiring braces, instead
of following C where they're optional for a single statement. Parsing
such constructs is not brain surgery but evidently it was beyond the
ability of Larry Wall at the time (his claims of world class computer
linguist notwithstanding). Too, superficially it sounds like one of those
simplifications that are quite reasonable. However, putting braces around
single statements is tedious and error prone (as I'm sure all Pythonistas
will agree). Instead of correcting the first mistake I surmise that Mr. Wall
(typically) patched it with a second, bigger wart, the "x if y;" form.
> But, if you're going to
> pick on perl's "x || y" idiom, keep in mind that you *can* do exactly
> the same thing in python:
I understand and in including the idiom in a list of where Perl goes
"overboard" I do not mean to fully condemn it. I include it only to
show that the list is long.
However, I'd point out that it's not exactly the same in the two
languages, as in Perl you can say
open( foo ) || print "couldn't open $foo\n";
while in Python such usage is strictly limited to expressions.
Also, as you point out, it's culturally taboo.
I agree that in many instances the bigger differences (beyond mere
syntax, where Perl truly suffers) are cultural rather than actual.
In fact that was a central point of my 'nit pick' about the slogan.
James J. Besemer 503-280-0838 voice
http://cascade-sys.com 503-280-0375 fax
mailto:jb at cascade-sys.com
More information about the Python-list