nargs is an argparse parameter that controls how many command-line values an argument accepts. It lets a program require one or more values, permit zero or more, or accept an optional value. section 6.5
Use these common nargs values:
- `'?'` accepts zero or one value. section 6.1.1
- `'*'` accepts zero or more values. section 6.1.1
- `'+'` requires one or more values. section 3.1
Accepting picnic items
Define a positional argument with `nargs='+'` when the program needs at least one item: `parser.add_argument('item', nargs='+', help='Item(s) to bring')` With no item, argparse reports an error; with `chips`, the program receives the supplied item. section 3.1
Reading optional file inputs
Use `nargs='*'` for zero or more files. Combined with `type=argparse.FileType('rt')` and `default=[sys.stdin]`, the program can process named readable files or standard input. section 6.3.1
Table 6.1 Possible values for nargs (view table figure)
Use the table to compare the three symbolic nargs values and their accepted argument counts. section 6.1.1
