Skip to content

Commit

Permalink
Just putting this here
Browse files Browse the repository at this point in the history
  • Loading branch information
ravomavain committed Jul 14, 2015
1 parent 33ba1ee commit b0df31c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from distutils.util import strtobool

def ask(question, default=True):
prompt = question
if default == None:
prompt += ' [y/n] '
elif default:
prompt += ' [Y/n] '
else:
prompt += ' [y/N] '
while True:
try:
ans = input(prompt).strip()
if ans == '' and default != None:
return default
return bool(strtobool(ans))
except ValueError:
print('Please respond with \'y\' or \'n\'.\n')

0 comments on commit b0df31c

Please sign in to comment.