If the -hdefault help means then this is all you need (this help is already excluded)
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('file')
parser.add_argument('-s','--schema')
parser.parse_args('-h'.split())
production
usage: stack23951543.py [-h] [-s SCHEMA] file
...
-h - , -x. ,
parser = argparse.ArgumentParser()
parser.add_argument('-s','--schema', default='meaningful default value')
mxg = parser.add_mutually_exclusive_group(required=True)
mxg.add_argument('-x','--xxx', action='store_true')
mxg.add_argument('file', nargs='?')
parser.parse_args('-h'.split())
:
usage: stack23951543.py [-h] [-s SCHEMA] (-x | file)
-x file ( ). -s , , , . -x, -s.
args , , args.file None, args.schema .
( , ):
An argument_group mutually_exclusive_group. . SO (. "Related" ), Python. , , , , parse_args. usage.
An argument_group .
A mutually_exclusive_group usage ( ), parse_args. "" , , .
http://bugs.python.org/issue11588 , "". , "" , , . , , , API. , argparse - " ".