繁体   English   中英

如何在Emacs中的python-shell-send-buffer上重新加载python模块?

[英]How to reload python modules on python-shell-send-buffer in Emacs?

当我使用python-shell-send-buffer (Cc Cc)时,可以看到python shell中主缓冲区的更改。

但是,如果我的缓冲区已导入模块,则不会重新加载它们。 如何解决?

例如:
main.py:

from functions import foo
print 'a'

functions.py:

def foo():
    print 'bcdef'

因此,如果我更改foo()并在main.py上运行python-shell-send-buffer 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-mode设置变量:

(setq
   python-shell-interpreter "ipython"
   python-shell-interpreter-args "--profile=dev"
)

以该配置开始的IPython在向其重新发送代码时将重新加载模块。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM