0

我正在尝试在基于 ptpython 的自定义 shell 中调用自定义输入挂钩。我按照文档中的说明进行操作,但我一定做错了:从未调用自定义挂钩。

这是使用最新的 ptpython (3.0.16) 和提示工具包 (3.0.18) 重现问题的示例:

Python 3.7.10 (default, Feb 26 2021, 18:47:35) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ptpython.repl import PythonRepl
>>> from prompt_toolkit.eventloop import set_eventloop_with_inputhook
>>> def my_hook(hook_context):
...   breakpoint() #this is just to see if this will be executed
... 
>>> set_eventloop_with_inputhook(my_hook)
<_UnixSelectorEventLoop running=False closed=False debug=False>
>>> pr=PythonRepl()
>>> pr.run()
>>> ... whatever I try, no breakpoint => my_hook is never called ...

知道我做错了什么吗?

4

0 回答 0