Loading topic
sys.argv) and that it reports success or failure through an exit code. Here you will create an ArgumentParser and turn that li2 min readparse_args.2 min readparse_args, and that you have seen positional arguments. Here you add optional arguments to a parser.2 min readadd_argument. It covers the action parameter, which controls what argparse does with a value once it finds the option on the command line.2 min readArgumentParser, add positional arguments and options, and read the resulting namespace. It covers how argparse turns text into Python values and how to reject bad input before your program logic runs.2 min readadd_argument. It covers how many values an argument accepts, what it holds when the user omits it, and how to make an option mandatory.2 min readadd_argument and run it from main(argv). It covers how to make the -h output explain your tool.2 min readmain(argv) function. The function takes an optional argument list and returns an exit code. A program built this way is easy to run, easy2 min readadd_argument and that your program has a main(argv) function that returns an integer.2 min readArgumentParser, add options and flags with add_argument, and read the resulting Namespace. It covers two tools for organizing options: argument groups, which affect only the help text, and mutually exclusive groups, which affect validation.2 min readmain(argv). Tools like git commit and pip install use subcommands: a first word that selects an action, each with its own arguments.2 min readmain(argv) function as in the earlier chapters. Here you will test a tool without launching a subprocess.2 min readmain(argv=None) function that returns an exit code, and that you know how to create a virtual environment and run pip. It turns a script you run with python greet.py into a command you can type as greet.2 min readadd_subparsers and set_defaults, as in the previous chapter. Here you will remove the duplication that appears when several subcommands need the same options.2 min readmain(argv) and exit codes work. It gives you criteria for deciding whether argparse is the right tool for a project.2 min read