在emacs python shell中重新加载一个改变的python文件 [英] Reloading a changed python file in emacs python shell
问题描述
从我的阅读到目前为止,似乎
reload(modulename )
应该工作,但似乎没有。
也许只是关闭python shell并重新启动它就足够了,是否有一个命令,或者你只是手动执行?
编辑:看起来像python-send-defun和python-send-buffer是理想的,但是变化似乎并没有被传播。
似乎对我有用:
将一个文件(在你的PYTHONPATH中)称为test.py
def foo():
$ p然后在emacs python shell(或者更好的是ipython shell)中键入
print('bar')
$ $ $ $ $ $ $ $ $ $ $ $ $ $ code>>>>导入测试
>>> test.foo()
bar
现在修改test.py:
def foo():
print('baz')
>>>从/home/unutbu/pybin/test.py'>重新加载(测试)
< module'test'
>>> test.foo()
baz
In the emacs Python shell (I'm running 2.* Python) I am importing a .py file I'm working with and testing the code. If I change the code however I'm not sure how to import it again.
From my reading so far it seems that
reload(modulename)
should work, but it doesn't seem to.
Perhaps just shutting down the python shell and restarting it would be enough, is there a command for that or you just do it manually?
edit: It looks like python-send-defun and python-send-buffer would be ideal, but changes don't seem to be propagating.
It seems to work for me:
Make a file (in your PYTHONPATH) called test.py
def foo():
print('bar')
Then in the emacs python shell (or better yet, the ipython shell), type
>>> import test
>>> test.foo()
bar
Now modify test.py:
def foo():
print('baz')
>>> reload(test)
<module 'test' from '/home/unutbu/pybin/test.py'>
>>> test.foo()
baz
这篇关于在emacs python shell中重新加载一个改变的python文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!