When using python-mode
via python.el, having one Python shell per Python buffer is the default.
However, you can change this default behavior if what you want instead is for multiple Python buffers to share the same Python shell. To do so, after opening the first Python buffer, enter:
M-x python-set-proc
...which is documented:
Set the default value of `python-buffer' to correspond to this buffer.
If the current buffer has a local value of `python-buffer', set the
default (global) value to that. The associated Python process is the
one that gets input from C-c C-r et al when used in a buffer that
doesn't have a local value of `python-buffer'.
Then later, if you want a new Python buffer to use its own shell, enter:
M-x set-variable python-buffer [RET] nil [RET]
After doing so and then opening a new Python buffer, a new Python shell will be created for that buffer after entering python-switch-to-python
or C-c C-z
.
python-mode
. I wanted to switch over at some point but now I'm usingiPython
, which seems only compatible withpython-mode
. – Maloriemalory