Created
June 9, 2014 22:42
-
-
Save sapamja/f061e28e53551a5f5f03 to your computer and use it in GitHub Desktop.
yes_no_input
This file contains hidden or 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 yes_no(arg): | |
| """get input yes or no""" | |
| print '%s [y|n]:' % arg, | |
| if str(raw_input()).lower() == 'y': | |
| return True | |
| print 'Oops exiting!' | |
| return False | |
| def get_input(msg=None, password=False): | |
| """get user raw_input""" | |
| if password: | |
| import getpass | |
| input_str = str(getpass.getpass(prompt='%s' % msg)) | |
| else: | |
| if msg: | |
| print '%s:' % msg, | |
| input_str = str(raw_input()) | |
| if input_str: | |
| return input_str | |
| else: | |
| raise Exception("Exiting: no input") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment