Next / Previous / Contents / TCC Help System / NM Tech homepage

4.12. Args.__init__(): Constructor

This class checks the command line arguments and makes their values available.

pyrang
    def __init__(self):
        """Check and process command line arguments.
        """

For the method that builds the argparse.ArgumentParser instance that matches our command line arguments, see Section 4.13, “Args._buildParser(): Build the argument parser”.

pyrang
        #-- 1
        # [ self._parser  :=  an argparse.ArgumentParser instance that
        #       matches our command line arguments ]
        self._parser = self._buildParser()

Because we pass the namespace=self argument to the .arg_parse() method, the arguments are stored in self's namespace.

pyrang
        #-- 2
        # [ if sys.argv matches self._parser ->
        #     self  :=  self with invariants set from sys.argv
        #   else ->
        #     sys.stderr  +:=  error and usage messages
        #     stop execution ]
        self._parser.parse_args(namespace=self)