Skip to content

Instantly share code, notes, and snippets.

@sapamja
Created June 9, 2014 22:42
Show Gist options
  • Save sapamja/f061e28e53551a5f5f03 to your computer and use it in GitHub Desktop.
Save sapamja/f061e28e53551a5f5f03 to your computer and use it in GitHub Desktop.
yes_no_input
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