当我使用 python-shell-send-buffer (C-c C-c) 时,我可以在 python shell 中看到主缓冲区的变化。
但是如果我的缓冲区有导入的模块,它们不会被重新加载。如何修复?
例如:
main.py:
from functions import foo
print 'a'
函数.py:
def foo():
print 'bcdef'
因此,如果我更改 foo() 并在 main.py 上运行 python-shell-send-buffer - 它会给我相同的 foo() 第一次读取
a
bcdef # never changed
请您参考如下方法:
如果你想这样做 - 使用 ipython。
创建配置“dev”(或其他):
ipython profile create dev
[ProfileCreate] Generating default config file: u'/home/username/.config/ipython/profile_dev/ipython_config.py'
并将这些行添加到“ipython_config.py”:
c.InteractiveShellApp.extensions = ['autoreload']
c.InteractiveShellApp.exec_lines = ['%autoreload 2']
然后在 Emacs 配置中为 python 模式设置变量:
(setq
python-shell-interpreter "ipython"
python-shell-interpreter-args "--profile=dev"
)
使用此配置启动的 IPython 将在您向其重新发送代码时重新加载模块。
