spacepy.toolbox.query_yes_no¶
- spacepy.toolbox.query_yes_no(question, default='yes')[source]¶
Ask a yes/no question via raw_input() and return their answer.
“question” is a string that is presented to the user. “default” is the presumed answer if the user just hits <Enter>. It must be “yes” (the default), “no” or None (meaning an answer is required of the user).
The “answer” return value is one of “yes” or “no”.
- Parameters:
- questionstr
the question to ask
- defaultstr (optional)
- Returns:
- outstr
answer (‘yes’ or ‘no’)
- Raises:
- ValueError
The default answer is not in (None|”yes”|”no”)
Examples
>>> import spacepy.toolbox as tb >>> tb.query_yes_no('Ready to go?') Ready to go? [Y/n] y 'yes'