I do not prefer python-mode
. I would like a generic way so that I can understand emacs.
I wish the file be saved and python file
command then be run as if in a shell.
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityUse M-!
(M-x shell-command
) if you want to run a shell command,
e.g. python file.py
and print the output in a new buffer (*Shell
Command Output*
). That does not open a shell in a new buffer.
Use M-x shell
to run a shell in a new buffer as pointed by @NickD.
You could use M-x compile
with an appropriate compile-command
value. e.g. as a file-local variable:
# -*- compile-command: "python file.py"; -*-
Emacs will prompt you to save (or not) the file before running the command.
M-x shell RET
and execute commands in it.