|
@@ -10,3 +10,14 @@ def raw_input_with_default(prompt, default):
|
|
return raw_input(prompt)
|
|
return raw_input(prompt)
|
|
finally:
|
|
finally:
|
|
readline.set_pre_input_hook(None)
|
|
readline.set_pre_input_hook(None)
|
|
|
|
+
|
|
|
|
+def int_input_with_default(prompt, default):
|
|
|
|
+ if default:
|
|
|
|
+ default = str(default)
|
|
|
|
+ else:
|
|
|
|
+ default = ''
|
|
|
|
+ s = raw_input_with_default(prompt, default).strip()
|
|
|
|
+ if s:
|
|
|
|
+ return int(s)
|
|
|
|
+ else:
|
|
|
|
+ return None
|