What is Python?

Grant Griffin g2 at seebelow.org
Wed Sep 20 17:12:37 EDT 2000


Tim Hammerquist wrote:
> 
> Grant Griffin <g2 at seebelow.org> wrote:
> > Of course, I don't expect that eveyone will share this sensibility; if
> > Perl makes sense to _you_, more power to 'ya.  But I did it off-and-on
> > for three years, and my fingers did a lot of walking through the
> > camel--they probably walked a mile for it.
> 
> I found I had to do a lot of extra research to become fluent in Perl as
> well.  However, nothing truly worthwhile comes too easily, right?  ;)
> 
> > But my own theory is that Perlers actually revel in the nonsensicalness
> > of their language, much as a tight-rope walker proudly calls attention
> > to his lack of a net.  <<karl walenda died>>  It's an ego thing.  That
> > explains the one-liners and the "just another perl hacker" thing.
> 
> We do, to a point, revel in this.  And ego is definitely rampant in
> clpm.
> 
> > By the way, here's my own personal Python JAPH implementation:
> >
> >       print "just another perl hacker"
> 
> Coincidentally, and I don't want to hurt your pride, but this is also
> Larry Wall's implementation.  Apparently he has also become tired of all
> these cutesy little tricks.  Of course, Larry would remember to put a
> semi-colon after that statement if there were more than one statement in
> the codeblock... would you?  ;)

I doubt it: in the Python I wrote above, a semicolon would be tolerated,
but it isn't required or even encouraged. <wink>

My bigger problem nowadays is accidentally putting single-quotes around
strings in C.  (Either double- or single-quotes will work in Python, but
I tend to use single-quotes because they make for less of that nasty
"punctuation clutter" that I left Perl to get away from. <wink>)

> > But in terms of your point about "the best tool for the job", one _does_
> > have to admit in all fairness that there's at least _one_ thing that
> > Perl is an order-of-magnitude better at than Python: execute Perl
> > scripts.
> 
> How 'bout regexps?  Perl didn't create regexps, so why bag on them as
> some in this thread have done?  Unix operations demanded the existence
> of regex pattern matching and Perl, which was so obviously derived from
> several Unix tools, accomplishes them very well.  I've noticed Pythoners
> like to stand on soapboxes and look down on regexps. ("A true Python
> solution wouldn't use regex's.")  Why look down on something so
> powerful?  Regexps are optimized for matching text against patterns as
> quickly and efficiently as possible, whereas you can only have so many:
...

I personally have a different perspective that that on regular
expressions.  I'm basically competant in them, but I've never really
"mastered" them.  So I remain uncomfortable with them, and I always have
to keep my handy reference chart at hand.  (It's my own loose
translation of the story of "The Little Engine That Could" that I found
in the Camel book. <wink>)  So I regard REs as a very useful thing, but
I'm much happier to use Python's "string" module when I can--which is
most of the time.

(BTW, Guido's Regular Expression TCL program in the demo of the Python
source distribution is a *very* useful interactive RE tester.  I wish it
were given more prominence within the Python world: It should be
included in main Python 2.0 distribution. <hint hint, big hint>)  

Actually, when I first took up Perl, I looked for something _like_
Python's string module, but I found none; I eventually figured out that
you were supposed to do all such things with REs.  That's great once you
master them (which, again, I can't say I ever truly did: the Camel book
would win a Pulitzer Prize here if the Pulitizer folks had a category
for "Worst Technical Writing" <0.1 wink>), but REs represent a major
hurdle for beginners.  OTOH, beginning Pythoneers can do most things
with the string module (which is useful in even for experienced
Pythonistas), then eventually master REs, as time permits.

To be fair, though, one of the few things I miss about Perl is its easy
use of REs: that's obviously one of its great strengths.  However,
Python's approach of providing that same functionality as a module, not
as a fundamental language feature, is definitely more "Pythonic": the
result is significantly more verbose, but that's exactly the point:
there's quite a lot of "implicit is worse than explicit" (to coarsely
paraphrase) baggage that comes along with Perl's approach.

...

> 
> > But I guess if the mettle of a scripting language is to be judged by its
> > one-linerability, I should confess that Python is a dismal failure: if
> > you put together its use of indents for blocks, with the fact that none
> > but its most elemental functions are built-in...well...it's hardly
> 
> What elemental functions aren't built-in?  I was under the impression
> that core modules were built-in, they simply exist in a separate
> namespace?

I'm not an expert on this, but AFAIK, they're just modules like any
other.  Most are implemented in Python; the rest are implemented as C
code compiled into DLLs (at least on Windows).

All of Python's actual "built-ins" are listed in the docs on a single
HTML page.  Python also has about a half-dozen "statements", which are
described in a series of short pages in the language reference.  AFAIK,
everything else in Python is a module written Python, or as a compiled
extension module.  Even the very powerful Numerical Python (which, to
the user feels exactly like a built-in part of the language except that
you have to import it) is just a compiled extension module.

i-heard-somewhere-that-this-is-level-of-modularity-one-of-the
   -major-design-goals-of-the-TBD-perl6-<wink>-ly y'rs,

=g2
-- 
_____________________________________________________________________

Grant R. Griffin                                       g2 at dspguru.com
Publisher of dspGuru                           http://www.dspguru.com
Iowegian International Corporation	      http://www.iowegian.com



More information about the Python-list mailing list