Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My comment on <a href="https://stackoverflow.com/questions/501626/both-python-2-and-3-in-emacs/502422#502422">this answer</a>. </p> <p>I wrote /t/min.py which will run fine in python3 but not in python2 (dictionary comprehension works in python3)</p> <p>Contents of /t/min.py</p> <pre><code>#!/usr/bin/python3 # -*- py-python-command: "/usr/bin/python3"; -*- a = {i:i**2 for i in range(10)} print(a) </code></pre> <p>Note that the shebang indicates python3 and the file local variable py-python-command too.</p> <p>I also wrote /t/min-py.el which makes sure that python-mode.el (ver 5.1.0)is used instead of python.el.</p> <p>Contents of /t/min-py.el</p> <pre><code>(add-to-list 'load-path "~/m/em/lisp/") (autoload 'python-mode "python-mode" "Python Mode." t) ;; (setq py-python-command "python3") </code></pre> <p>Note that the last line is commented out.</p> <p>I start emacs with the following command:</p> <pre><code>emacs -Q -l /t/min-py.el /t/min.py &amp; </code></pre> <p>Now emacs is started with my alternate dotemacs /t/min-py.el and it opens /t/min.py.</p> <p>When I press C-c C-c to send the buffer to python, it says the "for" part is wrong and that indicates that python2 is being used instead of python3. When I press C-c ! to start the python interpreter, it says python 2.5 is started.</p> <p>I can even change the second line of /t/min.py to this:</p> <pre><code># -*- py-python-command: "chunkybacon"; -*- </code></pre> <p>and do this experiment again and emacs still uses python2.</p> <p>If the last line of /t/min-py.el is not commented out, then C-c C-c and C-c ! both use python3.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload