base.add_argument('--arg', action='store_true')
main = argparse.ArgumentParser(parents=[base])
subparser = main.add_subparsers().add_parser('test', parents=[base])
print(main.parse_args('--arg test'.split()).arg)
print(main.parse_args('test --arg'.split()).arg)
Python: argument parser that handles global options to sub-commands properly