【发布时间】:2016-10-21 23:11:46
【问题描述】:
python 有atexit 模块来注册函数以在关闭解释器之前运行。 This question 很好,为什么不调用 atexit。
我想知道ipython 是否可以在退出使用%run <name> 运行的东西之前注册一个函数?理想情况下,我想创建一个装饰器,可以在任何一个中使用寄存器
模块取决于解释器。
【问题讨论】:
-
在
%run之后没有特别触发的东西,但你可以define a custom magic 执行%run加上一些操作,或者provide a post_run_cell callback 在每个输入执行后运行。跨度>
标签: ipython python-3.5 ipython-magic