Parsing a commandline from within Python
Steven Bethard
steven.bethard at gmail.com
Thu Oct 11 13:19:40 EDT 2007
andreas.huesgen at arcor.de wrote:
> Is there any buildin function which mimics the behavior of the
> standard commandline parser (generating a list of strings
> "foo bar" and "some text" from the commandline
> <"foo bar" "some text">)?
Try the shlex module::
>>> import shlex
>>> shlex.split('"foo bar" "some text"')
['foo bar', 'some text']
STeVe
More information about the Python-list
mailing list