0

I have had difficulties to run any python code when using python-execute-file (SPC m c c in spacemacs), until I finally found out that I have to use python-shell-send-buffer (SPC m s b in Spacemacs) to run code.

I wonder what is the purpose of python-execute-file then?

  • I don't think there is a python-execute-file function in python mode, but Spacemacs seems to have a function with a similar name: spacemacs/python-execute-file. – Omar Oct 7 '17 at 1:52
2

FWIW, in vanilla emacs, I cannot find python-execute-file, but looks like it is similar to python-shell-send-file in stock emacs.

  • python-shell-send-file (bound by default to C-c C-l) prompts the user to select the file they want to send to the python-shell-interpreter (default value is "python").. it need not be the current file or one of the open Python files.
  • python-shell-send-buffer (bound by default to C-c C-c) sends the current buffer to the python-shell-interpreter without asking any questions.

So if you want to quickly want to evaluate the script you are currently working on, you would use python-shell-send-buffer. But if you want to evaluation some other file (already open or not), you would use python-shell-send-file (or may be python-execute-file).

| improve this answer | |
  • I think it's something different. It sais: spacemacs/python-execute-file is an interactive Lisp function. [...] Execute a python script in a shell. – user430 Jun 7 '17 at 15:30
  • Is it possible to send only a highlighted region of a buffer? – fraxture Jan 2 '19 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.