On Sun, 08 Jul 2007 09:59:29 +0000, vvikram wrote: > > I want to call some function from my program and just pass it a > commandline. It should parse the commandline and return back a list of > parsed arguments (just like the sys.argv list) > > Example: > foo.parse_cmdline("/usr/bin/foorun -v -d -h") > ==> ['/usr/bin/foorun', '-v', '-d','-h'] > > Any suggestions on how to do this are appreciated.
def parse_cmdline(s): """Split a command line string s into words.""" import shlex return shlex.split(s) -- Steven. -- http://mail.python.org/mailman/listinfo/python-list