Function: org-babel-python-evaluate-external-process

org-babel-python-evaluate-external-process is a byte-compiled function defined in ob-python.el.gz.

Signature

(org-babel-python-evaluate-external-process BODY &optional RESULT-TYPE RESULT-PARAMS PREAMBLE GRAPHICS-FILE)

Documentation

Evaluate BODY in external python process.

If RESULT-TYPE equals output then return standard output as a string. If RESULT-TYPE equals value then return the value of the last statement in BODY, as elisp. If GRAPHICS-FILE is non-nil, then save graphical results to that file instead.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-python.el.gz
(defun org-babel-python-evaluate-external-process
    (body &optional result-type result-params preamble graphics-file)
  "Evaluate BODY in external python process.
If RESULT-TYPE equals `output' then return standard output as a
string.  If RESULT-TYPE equals `value' then return the value of
the last statement in BODY, as elisp.  If GRAPHICS-FILE is
non-nil, then save graphical results to that file instead."
  (let ((raw
         (pcase result-type
           (`output (org-babel-eval (org-babel-python--command nil)
				    (concat preamble (and preamble "\n")
                                            (if graphics-file
                                                (format org-babel-python--output-graphics-wrapper
                                                        body graphics-file)
                                              body))))
           (`value (let ((results-file (or graphics-file
                                           (org-babel-temp-file "python-"))))
		     (org-babel-eval (org-babel-python--command nil)
		      (concat
		       preamble (and preamble "\n")
		       (format
			(concat org-babel-python--def-format-value "
def main():
%s

__org_babel_python_format_value(main(), '%s', %s)")
                        (org-babel-python--shift-right body)
			(org-babel-process-file-name results-file 'noquote)
			(org-babel-python-var-to-python result-params))))
		     (org-babel-eval-read-file results-file))))))
    (org-babel-result-cond result-params
      raw
      (org-babel-python-table-or-string raw))))