[Python-Dev] shellwords (original) (raw)

Gustavo Niemeyer niemeyer@conectiva.com
Wed, 16 Apr 2003 12:29:44 -0300


Can shlex not be convinced to do what you want? (Yes, I saw your Q/A, but didn't quite understand it.)

Oh, sorry. Just now I noticed that you didn't understand it.

He was talking about that:

s = StringIO.StringIO("foo 'bar'asd'foo'") l = shlex.shlex(s) l. l.class l.error_leader l.pop_source l.source l.doc l.filestack l.push_source l.sourcehook l.init l.get_token l.push_token l.state l.module l.infile l.pushback l.token l.commenters l.instream l.quotes l.whitespace l.debug l.lineno l.read_token l.wordchars l.readtoken() 'foo' l.readtoken() "'bar'" l.readtoken() "asd'foo'"

In constrast to:

shellwords.shellwords("foo 'bar'asd'foo'") ['foo', 'barasdfoo']

And also:

[niemeyer@localhost ~/src]% echo foo 'bar'asd'foo' foo barasdfoo

-- Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]