[Python-mode] [Bug 310354] Re: 3.0 execute into python session
Andreas Röhler
andreas.roehler at online.de
Thu Jun 23 19:06:21 CEST 2011
Am 13.06.2011 23:02, schrieb Barry Warsaw:
> There are a couple of issues here.
>
> I'd like to see python-mode eventually grow better support for Python 3
> and Python 2 at the same time. Probably Python 3 support should be a
> derived major-mode so things that are unique to it can be handled
> separately from Python 2 support. It would then be nice if python-mode
> could auto-detect which to use when possible (this will sometimes be
> difficult), or provide an easy way for the user to specify or switch to
> python3-mode (e.g. via an auto-mode-alist or some such). Definitely
> python-mode.el should at least keep a local variable that tells you
> whether the current buffer is Python 2 or Python 3.
>
> * Now, when you have such a variable, functions like py-execute-file can
> switch on that to decide what Python code to exec. For Python 3, I'd
> actually run something like this snippet:
>
> with open(r'%s') as python_mode_exec_hack:
> exec(python_mode_exec_hack.read())
Hi Barry,
while it seems pretty close at finish, just to communicate some changes:
If that local variable mentioned --lets call it py-which-shell-- doesn't
exist, shebang, import will be queried, finally recurring to installed
default Python.
Ie in that (new) order:
(setq active-shell (or py-which-shell
(py-choose-shell-by-shebang)
(py-choose-shell-by-import)
installed-system-default-python
M-x py-toggle-shell without arg will switch between Cpython und Jython -
similar as now, but no numeric args required any more,
while with C-u prompts for specific Python version - any reachable might
be given, python2.7, python3.1 or whatever.
Cheers,
Andreas
More information about the Python-mode
mailing list