What is Python?

Grant Griffin g2 at seebelow.org
Fri Sep 22 17:14:09 EDT 2000


Tim Hammerquist wrote:
> 
> Grant Griffin <g2 at seebelow.org> wrote:
> > 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>)
> 
> I also prefer single-quotes, unless I'm quoting a real language.  I
> don't like:
> 
>         "And God said unto the gerbil, \"Do not chew your owners table.\"."
> nor
>         'It\'s not their table.'
> 
> and I very much like the _ability_ (but not duty) of defining my own quote
> character in Perl:
> 
>         qq{And God said, "Are you talkin' to me?! Huh, $gerbil_name?!}
> 
> > 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.
> 
> Nothing wrong with looking in the book.  One can guess, though, by your
> discomfort with regexps, that you've not worked extensively in a *nix
> shell?

Right.  I'm a Windows guy by training.

REs certainly are useful skill to master, but in my case they fall
fairly far down on my own list.  (For example, awhile back I learned how
to change sampling rates by non-integer factors, and more recently I've
recently been learning Numerical Python.)

> 
> > Actually, when I first took up Perl, I looked for something _like_
> > Python's string module, but I found none;
> 
> Um, Perl built-ins:
>         perldoc -f join
>         perldoc -f split
...

Split and join by themselves solve only a tiny fraction of
text-processing problems (which obviously is why Perl also includes
REs.)  OTOH, if you look at Python's string module, you'll see that it
does a lot of useful things besides just split and join.  Its complete
set of functions cover most basic string-processing jobs (thus its name
<'wink' expurgated>)  For example, it does the common operations of
eliminating leading and trailing whitespace, and it does simple caps
manipulations.

If you're not afraid to do string manipulations in multiple statements
by breaking them up into little pieces, Python's string module (along
with Python's sequence operations) can solve some pretty sophisticated
string processing problems.  Of course, the Masters of REs probably
would pride themselves on writing a single complicated RE for things
that could be done with a few Python string calls.  However, even in
Perl, I tended to break such things up into little pieces.  I quickly
found that there was no percentage in making big, complicated REs
because it is impossible to debug them without breaking them up. (Also,
in Perl I didn't have Guido's RE demo to help me interactively hone my
REs. <'wink' expurgated>)

simple-is-better-than-complex-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