Filtering the results of starting a running process in emacs / elisp

I have the following code to run python and get the result in the buffer from scratch.

(defun hello () "Test, just prints Hello, world to mini buffer" (interactive) (start-process "my-process" "*scratch*" "python" "/Users/smcho/Desktop/temp/hello.py") (message "Hello, world : I'm glad to see you")) (define-key global-map "\C-ck" 'hello) 

The python code is as follows.

 if __name__ == "__main__": print "hello, world from Python" 

Using Cc k gives me the following code in the buffer from scratch.

  hello, world from Python

 Process my-process finished

I do not need the last part, since it is not from python. Is there a way to not get this line or delete it effectively?

Added

Trey helped me get the answer.
 (defun hello () "Test, just prints Hello, world to mini buffer" (interactive) (insert (shell-command-to-string "python /Users/smcho/Desktop/temp/hello.py")) (message "Hello, world : I'm glad to see you")) (define-key global-map "\C-ck" 'hello) 
+2
source share
1 answer

You tried

 (shell-command-to-string "/Users/smcho/Desktop/temp/hello.py") 

This will return a string that you can insert into the zero buffer like this:

 (with-current-buffer "*scratch*" (insert (shell-command-to-string "/Users/smcho/Desktop/temp/hello.py"))) 
+3
source

All Articles