Ask/prompt the user for a short piece of data. Recipe 577098 is a much more generic/functional (but longer) take on this.
1 2 3 4 5 6 7 8 9 10 | def query(question, default=None):
s = question
if default:
s += " [%s]" % default
s += ": "
answer = raw_input(s)
answer = answer.strip()
if not answer:
return default
return answer
|