Closed GoogleCodeExporter closed 9 years ago
Have you tried parser.parse_known_args()?
Another option is an undocumented feature in the repository, argparse.REMAINDER:
parser = argparse.ArgumentParser(prog='PROG')
parser.add_argument('command')
parser.add_argument('args', nargs=argparse.REMAINDER)
print parser.parse_args()
At the command line:
$ prog.py X --foo B
Namespace(args=['--foo', 'B'], command='X')
This could become a documented feature if it solves your problem cleanly. Let
me know.
Original comment by steven.b...@gmail.com
on 7 Jan 2010 at 5:09
Original comment by steven.b...@gmail.com
on 28 Feb 2010 at 10:09
Original comment by steven.b...@gmail.com
on 23 Jul 2010 at 12:13
I had the same problem and used the argparse.REMAINDER solution and it worked
great. Adding this to the documentation would be very helpful.
Original comment by jzwi...@gmail.com
on 12 Jul 2011 at 9:30
Original issue reported on code.google.com by
bioinformed@gmail.com
on 28 Dec 2009 at 1:45