python-mode creates an inferior process via 'make-comint
, which uses 'start-file-process
, which creates the process relative to the variable 'default-directory
. So there are a few ways you can tackle this beast.
The first is to change 'default-directory
to be something local, like:
(add-hook 'python-mode-hook (lambda () (setq default-directory "~"))
That has the downside that C-x C-f now behaves differently (starting at ~
).
Another is to change the 'default-directory
just for the invocation of 'py-shell
, like so (untested):
(defadvice py-shell (around py-shell-different-directory activate)
"set default-directory just for py-shell"
(let ((default-directory "~"))
ad-do-it))