code: def check_usage (docstring, argv=None, usageifnoargs=False):
      
      if argv is None:
          from sys import argv
  
      if len (argv) == 1 and usageifnoargs:
          show_usage (docstring, (usageifnoargs != 'long'), None, 0)
      if len (argv) == 2 and argv[1] in ('-h', '--help'):
          show_usage (docstring, False, None, 0)
docs: Check if the program has been run with a --help argument; if so,
      print usage information and exit.
  
      :arg str docstring: the program help text
      :arg argv: the program arguments; taken as :data:`sys.argv` if
          given as :const:`None` (the default). (Note that this implies
          ``argv[0]`` should be the program name and not the first option.)
      :arg bool usageifnoargs: if :const:`True`, usage information will be
          printed and the program will exit if no command-line arguments are
          passed. If "long", print long usasge. Default is :const:`False`.
  
      This function is intended for small programs launched from the command
      line. The intention is for the program help information to be written in
      its docstring, and then for the preamble to contain something like::
  
          \"\"\"myprogram - this is all the usage help you get\"\"\"
          import sys
          ... # other setup
          check_usage (__doc__)
          ... # go on with business
  
      If it is determined that usage information should be shown,
      :func:`show_usage` is called and the program exits.
  
      See also :func:`wrong_usage`.