When I use python-shell-send-buffer
(Cc Cc) I can see changes from my main buffer in python shell.
But if my buffer has imported modules they are not reloaded. How can it be fixed?
For exmple:
main.py:
from functions import foo
print 'a'
functions.py:
def foo():
print 'bcdef'
So if I change foo()
and run python-shell-send-buffer
on main.py - it gives me the same foo()
it read 1st time
a
bcdef # never changed
If you want to do this - use ipython.
Create configuration "dev" (or whatever):
ipython profile create dev
[ProfileCreate] Generating default config file: u'/home/username/.config/ipython/profile_dev/ipython_config.py'
And add these lines to "ipython_config.py":
c.InteractiveShellApp.extensions = ['autoreload']
c.InteractiveShellApp.exec_lines = ['%autoreload 2']
Then set variables in Emacs config for python-mode:
(setq
python-shell-interpreter "ipython"
python-shell-interpreter-args "--profile=dev"
)
IPython started with this config will reload modules when you resend code to it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.