I want to get all the remaining unused arguments at once. How do I do it?
parser.add_argument(\'-i\', action=\'store\', dest=\'i\', default=\'i.log\')
parser.add
Another option is to add a positional argument to your parser. Specify the option without leading dashes, and argparse will look for them when no other option is recognized.
This has the added benefit of improving the help text for the command:
>>> parser.add_argument('otherthings', nargs='*')
>>> parser.parse_args(['foo', 'bar', 'baz'])
Namespace(i='i.log', o='o.log', otherthings=['foo', 'bar', 'baz'])
and
>>> print parser.format_help()
usage: ipython-script.py [-h] [-i I] [-o O] [otherthings [otherthings ...]]
positional arguments:
otherthings
optional arguments:
-h, --help show this help message and exit
-i I
-o O