class CustomShell(code.InteractiveConsole): def raw_input(self, *args, **kw): try: import readline except ImportError: pass try: return code.InteractiveConsole.raw_input(self, *args, **kw)