--num is a long command-line option for choosing a quantity used by a program. It accepts an integer and supplies a program-specific default when omitted. section 11.1 section 13.0
The option’s meaning and validation depend on the program:
- bottles.py defaults to 10 verses, rejects non-integers automatically through argparse, and rejects values below 1 with parser.error(). section 11.1
- twelve_days.py defaults to 12 days and restricts the value to the range 1–12 before generating verses. section 13.1
- wod.py defaults to four exercises and passes the value as the sample size for random.sample(). section 19.1 section 19.1.5
- password.py uses --num for the number of passwords, while --num_words separately controls words per password. section 20.1
$ ./bottles.py -h
usage: bottles.py [-h] [-n number]
Bottles of beer song
optional arguments:
-h, --help show this help message and exit
-n number, --num number
How many bottles (default: 10)
The help output shows the short alias -n, integer-valued argument, and default of 10 for bottles.py. section 11.1
$ ./twelve_days.py -h
usage: twelve_days.py [-h] [-n days] [-o FILE]
Twelve Days of Christmas
optional arguments:
-h, --help show this help message and exit
-n days, --num days Number of days to sing (default: 12)
-o FILE, --outfile FILE
Outfile (default: <_io.TextIOWrapper name='<stdout>'
mode='w' encoding='utf-8'>)
The twelve_days.py help output shows --num alongside --outfile and documents its default of 12. section 13.1
