Asks for a single choice out of multiple items.
    Given those items, and a prompt to ask the user with
436048
def get_choice(prompt, choices):
    
    print()
    checker = []
    for offset, choice in enumerate(choices):
        number = offset + 1
        print("\t{}): '{}'\n".format(number, choice))
        checker.append(str(number))

    response = get_input(prompt, tuple(checker) + ('',))
    if not response:
        print("Exiting...")
        exit()

    offset = int(response) - 1
    selected = choices[offset]

    return selected
543787
function Prompt() {
  BasePrompt.apply(this, arguments);
  if (typeof this.question.source !== 'function') {
    throw new TypeError('expected source to be defined');
  }

  this.currentChoices = [];
  this.firstRender = true;
  this.selected = 0;

  // Make sure no default is set (so it won't be printed)
  this.question.default = undefined;
  this.paginator = new Paginator();
}
893810
def question(self, n):
        
        print("")
        prompt_ask = raw_input("{0} [K/O/R/D/M/Q]? ".format(n))
        print("")
        if prompt_ask in ("K", "k"):
            self.keep()
        elif prompt_ask in ("O", "o"):
            self._overwrite(n)
        elif prompt_ask in ("R", "r"):
            self._remove(n)
        elif prompt_ask in ("D", "d"):
            self.diff(n)
            self.i -= 1
        elif prompt_ask in ("M", "m"):
            self.merge(n)
        elif prompt_ask in ("Q", "q", "quit"):
            self.quit()
943334
def multiple_choice(name, choices = [], options = {})
      field name, MultipleChoiceField.new(choices, options)
    end
1184188
def choose(key, *choices)
    all_choices = choices.flatten
    index = (get_unit(key) * all_choices.length).floor
    index = all_choices.length - 1 if index > all_choices.length - 1
    all_choices[index]
  end
1236325
def multchoicebox(message='Pick as many items as you like.', title='', choices=['program logic error - no choices specified']):
    
    return psidialogs.multi_choice(message=message, title=title, choices=choices)
1088617
def checkbox_multiple_choice(name, choices = [], options = {})
      field name, MultipleChoiceField.new(choices, options.merge(widget: Widgets::CheckboxSelectMultiple.new))
    end
169657
def _prompt(pre_prompt, items, post_prompt, default, indexed, stream):
    '''
    
    '''
    # try to sub in the default if provided
    if default is not None:
        if '{}' in pre_prompt:
            pre_prompt = pre_prompt.format(default)
        if '{}' in post_prompt:
            post_prompt = post_prompt.format(default)
    # build the item strings
    item_format = "{indent}{item}"
    if indexed:
        item_format = "{indent}[{index}] {item}"
    item_text_list = []
    indent = '  '
    for index, item in enumerate(items):
        item_text = ''
        components = {
            'indent': indent,
            'item': item
        }
        if indexed:
            components['index'] = index
        item_text = item_format.format(**components)
        item_text_list.append(item_text)
    # build full menu
    menu_parts = [pre_prompt] + item_text_list
    full_menu = '\n'.join(menu_parts) + '\n'
    stream.write(full_menu)
    stream.flush()
    # Get user response
    # - py 2/3 compatibility
    get_input = input
    try:
        get_input = raw_input
    except NameError:
        pass
    # - actuall get input
    response = get_input(post_prompt)
    return response
1240101
def _choose(self):
        
        answer = "all"

        if not self.force:
            for i, value in enumerate(self.current_values):
                self.out("{:>2d}. {}".format(i + 1, value))

            answer = self.prompt(
                'Which value to remove? Enter number or "all": ')

        if answer != "all":
            try:
                answer = int(answer) - 1

                if answer < 0 or answer >= len(self.current_values):
                    answer = None
            except ValueError:
                answer = None

        return answer
57146
def pick(rest):
	""
	question = rest.strip()
	choices = util.splitem(question)
	if len(choices) == 1:
		return "I can't pick if you give me only one choice!"
	else:
		pick = random.choice(choices)
		certainty = random.sample(phrases.certainty_opts, 1)[0]
		return "%s... %s %s" % (pick, certainty, pick)
588699
function ask(cb) {
  return function(app) {
    app.use(store('smithy'))
      .use(questions())
      .ask(function(err, answers) {
        if (err) return cb(err);

        cb.call(app, null, answers);
      });

    app.asyncHelper('ask', function(key, options, cb) {
      app.questions.options.force = true;
      app.ask(key, function(err, res) {
        if (err) return cb(err);
        cb(null, res[key]);
      });
    });
  };
}
1233286
function (question, defaultValue) {
  var choiceValues = _.map(question.choices, function (choice) {
    if (typeof choice === 'object') {
      return choice.value;
    } else {
      return choice;
    }
  });

  return choiceValues.indexOf(defaultValue);
}
1280203
public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null)
    {
        $helper = $this->getHelperSet()->get('question');

        $question = new ChoiceQuestion("<question>$question</question> ", $choices, $default);

        $question->setMaxAttempts($attempts)->setMultiselect($multiple);

        return $helper->ask($this->input, $this->output, $question);
    }
372463
def get_multiple_choices_required(self):
        
        errors = []
        if self.required:
            msg = _("At least one checkbox has to be selected.")
            errors.append(('$error.multifield', msg))
        return errors
1248239
def confirm(question, default=True):
    
    valid = {"": default, "yes": True, "y": True, "no": False, "n": False}
    while 1:
        choice = input(question + (" [Y/n] " if default else " [y/N] ")).lower()
        if choice in valid:
            return valid[choice]
        print("Please respond with 'y' or 'n' ")
250280
def create_single_poll(self, polls_question, polls_description=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - polls[question]
        """The title of the poll."""
        data["polls[question]"] = polls_question

        # OPTIONAL - polls[description]
        """A brief description or instructions for the poll."""
        if polls_description is not None:
            data["polls[description]"] = polls_description

        self.logger.debug("POST /api/v1/polls with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("POST", "/api/v1/polls".format(**path), data=data, params=params, no_data=True)
480899
def get_single_item(d):
    """"""
    assert len(d) == 1, 'Single-item dict must have just one item, not %d.' % len(d)
    return next(six.iteritems(d))