def install_readline(hook):
def hook_wrap():
try:
res = hook()
except KeyboardInterrupt as x: #this exception does not seem to be caught
res = ""
except EOFError:
return None
if res[-1:] == "\n":
return res[:-1]
else:
return res
class IronPythonWrapper(IronPythonConsole.IConsole):
def ReadLine(self, autoIndentSize):
return hook_wrap()
def Write(self, text, style):
System.Console.Write(text)
def WriteLine(self, text, style):
System.Console.WriteLine(text)
IronPythonConsole.PythonCommandLine.MyConsole = IronPythonWrapper()
评论列表
文章目录