Session Ready
Exercise

Argparse nbuild()

We will use the standard library argparse module to make a general command-line interface (CLI) function called argparse_cli() and apply this function to the nbuild() function from the previous chapter.

If you do not remember how nbuild() works, call help(nbuild).

In short, nbuild() returns a notebook object that contains one cell for each input file it receives.

We want argparse_cli() to be able to handle an indeterminate number of shell arguments.

To do this with argparse, we need to pass nargs='*' to the add_argument() method of an instance of the ArgumentParser class.

We will use our CLI to pass shell arguments to nbuild(), so that we can focus on CLI design and not on how the shell arguments are used.

Instructions
100 XP
  • Instantiate the parser object.
  • Add an argument called in_files to the parser object.