<s> """<STR_LIT>""" <EOL> import readline <EOL> from contextlib import contextmanager <EOL> @ contextmanager <EOL> def prepopulate ( default ) : <EOL> """<STR_LIT>""" <EOL> def hook ( ) : <EOL> readline . insert_text ( str ( default ) ) <EOL> readline . redisplay ( ) <EOL> if default is not None : <EOL> readline . set_pre_input_hook ( hook ) <EOL> yield <EOL> readline . set_pre_input_hook ( None ) <EOL> def ask ( question , suggestion = None ) : <EOL> """<STR_LIT>""" <EOL> prompt_str = question <EOL> if suggestion is not None and '<STR_LIT:\n>' in str ( suggestion ) : <EOL> prompt_str += '<STR_LIT>' <EOL> elif not prompt_str . endswith ( '<STR_LIT:U+0020>' ) : <EOL> prompt_str += '<STR_LIT:U+0020>' <EOL> with prepopulate ( suggestion ) : <EOL> return raw_input ( prompt_str ) . strip ( '<STR_LIT:U+0020>' ) <EOL> def yes_no ( question ) : <EOL> """<STR_LIT>""" <EOL> while True : <EOL> reply = raw_input ( question + '<STR_LIT>' ) . lower ( ) <EOL> if len ( reply ) == <NUM_LIT:0> or not reply [ <NUM_LIT:0> ] in [ '<STR_LIT:y>' , '<STR_LIT:n>' ] : <EOL> continue <EOL> return reply [ <NUM_LIT:0> ] == '<STR_LIT:y>' </s>
