Message128071
There are some problems that ‘=’ can’t solve, such as options with nargs ≥ 2. optparse has no trouble with this:
>>> parser = optparse.OptionParser()
>>> parser.add_option('-a', nargs=2)
>>> parser.parse_args(['-a', '-first', '-second'])
(<Values at 0x7fc97a93a7e8: {'a': ('-first', '-second')}>, [])
But inputting those arguments is _not possible_ with argparse.
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('-a', nargs=2)
>>> parser.parse_args(['-a', '-first', '-second'])
usage: [-h] [-a A A]
: error: argument -a: expected 2 argument(s) |
|
Date |
User |
Action |
Args |
2011-02-06 19:12:18 | andersk | set | recipients:
+ andersk, bethard, eric.smith, eric.araujo, r.david.murray, gdb, nelhage, drm |
2011-02-06 19:12:18 | andersk | set | messageid: <1297019538.75.0.803498628689.issue9334@psf.upfronthosting.co.za> |
2011-02-06 19:12:18 | andersk | link | issue9334 messages |
2011-02-06 19:12:18 | andersk | create | |
|