code: def extract_opts(**opts):
      
      values = {}
      for opt, init in opts.items():
          try:
              idx = sys.argv.index('-%s' % opt)
          except ValueError:
              continue
          if idx+1 < len(sys.argv):
              opts[opt] = sys.argv.pop(idx+1)
  
          sys.argv.pop(idx)
  
      return opts
docs: Small utility to extract a set of one-char options from sys.argv.