Last active
February 18, 2016 16:14
-
-
Save Visgean/14b5e3c01b32a008831d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def yesno(prompt, answers=None): | |
if answers is None: | |
answers = { | |
'yes': True, | |
'no': False | |
} | |
prompt = prompt.encode('ascii', 'ignore') | |
while True: | |
answer = raw_input(u'{0} [{1}]: '.format( | |
prompt, | |
u'/'.join(answers.keys()) | |
)) | |
if answer in answers: | |
return answers[answer] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment