Python advocacy

Paul Prescod paul at prescod.net
Tue Mar 7 22:27:51 EST 2000


Donn Cave wrote:
> 
> | I've never heard anyone as knowledgable about Python as you claim that
> | it is *not flexible enough* to compete with anything. In what way is
> | "sh" more flexible than Python.
> 
> Lexically, I guess would be the word.  I have in mind two things.
> The UNIX shell is what you get with a very domain specific language,
> the simplest functions in the problem domain (UNIX commands) can be
> written with no punctuation at all.  More complex operations can be
> expressed with only a little punctuation, e.g., a pipeline.  

Well I haven't said anything against pipes! I just don't think we need
"if", "foreach" and friends. That's the point at which you want to wrap
your commands and pipes in a language with data structures and text
processing features.

> For an example of Tcl's lexical flexibility, see the "expect" command
> from Don Libes' Expect package.  I think the Lisp & Scheme dialects
> can probably do the same kind of thing, and in this way they're more
> flexible than Python.

I guess I don't see a big problem with:

expect( "*number :*" )
sleep( 1 )
send( "r\r" )

Where little languages are useful, they can usually be embedded as we
have done with SQL, XPath, and pipes.

> Yes, I think "expect" is more powerful than any Python idiom I can
> think of to translate it to.  I think the shell is a more powerful
> way to operate UNIX commands.  I think this is not just the power
> to do something with less typing, it's also the power to do something
> with less investment in learning the ropes.

If you are going to learn expect without learning the "rest of TCL" then
I agree. My presumption is that everyone will (or at least should be
encouraged to) migrate from one-line commands to five-line hacks to 100
line toys to 1000 line tools (and perhaps beyond). I think that the
phase changes at those boundaries are actually harmful.

Also, I've pushed Python's lexical flexibility to its extremes and I am
rather glad that there is a point where it stops me! With too much
flexibility, it becomes a matter of learning a whole new syntax with
every module you import. More phase changes.

In the particular case of running system commands, I would prefer Python
to have some built-in syntax or function considering how often the task
is performed. Importing os is admittedly somewhat annoying for a really
tiny program.

-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for himself
Out of timber so crooked as that which man is made nothing entirely
straight can be built. - Immanuel Kant




More information about the Python-list mailing list