Arguments and options

In order to run programs, the shell parses a command line into words. The words can be understood as a mixture of options and arguments. The following are some essential guidelines:

  • Options come first. They are preceded by - or --. There are two formats: -l and --word. There are two species of options: options with no arguments and options with arguments. A couple of examples of options without arguments involve using -V to show a version or using --version to show the version. An example of an option with arguments is -m module, where the -m option must be followed by a module name.
  • Short format (single-letter) options with no arguments can be grouped behind a single -. We might use -bqv to combine the -b -q -v options for convenience.
  • Generally, arguments come after options, and they don't have a leading - or -- (although some Linux applications break this rule). There are two common kinds of arguments:
    • Positional arguments, where the order is semantically significant. We might have two positional arguments: an input filename and an output filename. The order matters because the output file will be modified. When files will be overwritten, simply distinguishing by position needs to be done carefully to prevent confusion. The cp, mv, and ln commands are rare examples of positional arguments where the order matters. It's slightly more clear to use an option to specify the output fileā€”for example, -o output.csv.
    • A list of arguments, all of which are semantically equivalent. We might have arguments that are all the names of input files. This fits nicely with the way the shell performs filename globing. When we say process.py *.html, the *.html command is expanded by the shell to filenames that become the positional parameters. (This doesn't work in Windows, so the glob module must be used.)

For more information, refer to: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02.

The Python command line has a dozen or so options that can control some details of Python's behavior. See the Python Setup and Usage document (https://docs.python.org/3/using/index.html) for more information on what these options are. The positional argument to the Python command is the name of the script that is to be run; this will be our application's topmost file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset