<s> import sys <EOL> class _Getch : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> try : <EOL> self . impl = _GetchWindows ( ) <EOL> except ImportError : <EOL> self . impl = _GetchUnix ( ) <EOL> def __call__ ( self ) : return self . impl ( ) <EOL> class _GetchUnix : <EOL> def __init__ ( self ) : <EOL> import tty , termios <EOL> def __call__ ( self ) : <EOL> import tty , termios <EOL> fd = sys . stdin . fileno ( ) <EOL> old_settings = termios . tcgetattr ( fd ) <EOL> try : <EOL> tty . setraw ( sys . stdin . fileno ( ) ) <EOL> ch = sys . stdin . read ( <NUM_LIT:1> ) <EOL> finally : <EOL> termios . tcsetattr ( fd , termios . TCSADRAIN , old_settings ) <EOL> return ch <EOL> class _GetchWindows : <EOL> def __init__ ( self ) : <EOL> import msvcrt <EOL> def __call__ ( self ) : <EOL> import msvcrt <EOL> if sys . version [ <NUM_LIT:0> ] < '<STR_LIT:3>' : <EOL> return msvcrt . getch ( ) <EOL> else : <EOL> return msvcrt . getch ( ) . decode ( ) </s>
