docs: def prompt(question, validator=None,
             choices=None, default_key=NotImplemented,
             normalizer=str.lower,
             _stdin=None, _stdout=None):
      """
      Prompt user for question, maybe choices, and get answer.
  
      Arguments:
  
      question
          The question to prompt.  It will only be prompted once.
      validator
          Defaults to None.  Must be a callable that takes in a value.
          The callable should raise ValueError when the value leads to an
          error, otherwise return a converted value.
      choices
          If choices are provided instead, a validator will be constructed
          using make_choice_validator along with the next default_value
          argument.  Please refer to documentation for that function.
      default_value
          See above.
      normalizer
          Defaults to str.lower.  See above.
      """
  
      def write_choices(choice_keys, default_key):
          _stdout.write('(')
          _stdout.write('/'.join(choice_keys))
          _stdout.write(') ')
          if default_key is not NotImplemented:
              _stdout.write('[')
              _stdout.write(choice_keys[default_key])
              _stdout.write('] ')
  
      if _stdin is None:
          _stdin = sys.stdin
  
      if _stdout is None:
          _stdout = sys.stdout
  
      _stdout.write(question)
      _stdout.write(' ')
  
      if not check_interactive():
          if choices and default_key is not NotImplemented:
              choice_keys = [choice for choice, mapped in choices]
              write_choices(choice_keys, default_key)
              display, answer = choices[default_key]
              _stdout.write(display)
              _stdout.write('\n')
  
              logger.warning(
                  'non-interactive mode; auto-selected default option [%s]',
                  display)
              return answer
          logger.warning(
              'interactive code triggered within non-interactive session')
          _stdout.write('Aborted.\n')
          return None
  
      choice_keys = []
  
      if validator is None:
          if choices:
              validator = make_choice_validator(
                  choices, default_key, normalizer)
              choice_keys = [choice for choice, mapped in choices]
          else:
              validator = null_validator
  
      answer = NotImplemented
      while answer is NotImplemented:
          if choice_keys:
              write_choices(choice_keys, default_key)
          _stdout.flush()
          try:
              answer = validator(
                  _stdin.readline().strip().encode(locale).decode(locale))
          except ValueError as e:
              _stdout.write('%s\n' % e)
              _stdout.write(question.splitlines()[-1])
              _stdout.write(' ')
          except KeyboardInterrupt:
              _stdout.write('Aborted.\n')
              answer = None
  
      return answer