Why does this argparse code behave differently between Python 2 and 3?
The following code, using argparse's subparsers, fails on Python 3 but runs as expected in Python 2. After comparing the docs, I still can't tell why. #!/usr/bin/env python from __future__ import print_function from argparse import ArgumentParser def action(args): print(args) if __name__ == '__main__': std = ArgumentParser(add_help=False) std.add_argument('standard') ap = ArgumentParser() sp = ap.add_subparsers() cmd = sp.add_parser('subcommand', parents=[std], description='Do subcommand') cmd.add_argument('arg') cmd.set_defaults(do=action) args = ap.parse_args() args.do(args) The output from