[Python-Dev] shellwords

Guido van Rossum guido@python.org
Wed, 16 Apr 2003 11:29:15 -0400


> > > [1] http://www.crazy-compilers.com/py-lib/shellwords.html
> > 
> > Hm, couldn't this be easily done with shlex?
> 
> >From the homepage:
> 
> """
> Frequently Asked Questions
> 
> Q: Hey, there is 'shlex' coming with Python. Why there is a need for
> this module? A: I know 'shlex' and I gave it a try. But 'shlex' takes
> quotes as word-delemiters which divers from the shell-semantic (see
> above). And even if 'shlex' would parse strings as needed, I would have
> written a (very, very) thin layer above, since 'shlex' is simple but
> seldomly used for this kind of job.
> """

I saw that after posting. :-(

The argument "'shlex' is simple but seldomly used for this kind of
job." seems circular though: "I'm not using shlex because it's rarely
used" ???

> I agree with him. Even disconsidering the fact of the syntax
> divergence, shellwords is about half the size of shlex, and it's
> much more confortable, allowing one liners like "for opt in
> shellwords(line):".

I know I've wished for this once or twice, but not badly enough to
bother solving the problem right.  I'm worrying that having too many
ways to do mostly the same thing adds clode bloat.

Couldn't adding something even smaller on top of shlex provide the
same interface and solve the syntactic divergence?

--Guido van Rossum (home page: http://www.python.org/~guido/)