diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-11-27 23:59:51 +0000 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2010-11-27 23:59:51 +0000 |
commit | 994e1648e2f99bf408c5ca0739bd6dcd0764f7cb (patch) | |
tree | b935c7449524dfb307c8ed7532235ef1b2d0dc5c | |
parent | 039f2480923912a33b071f9ea9201925c9441c29 (diff) | |
download | org-mode-994e1648e2f99bf408c5ca0739bd6dcd0764f7cb.tar.gz |
babel: python uses :return header argument
* lisp/ob-python.el (org-babel-execute:python): Use a :return header
argument for external evaluation in which the code block body need
be wrapped in a function
Thanks to Darlan Cavalcante for proposing this feature.
-rw-r--r-- | lisp/ob-python.el | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lisp/ob-python.el b/lisp/ob-python.el index 21b8ff1..cf93252 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -56,9 +56,12 @@ This function is called by `org-babel-execute-src-block'." (cdr (assoc :session params)))) (result-params (cdr (assoc :result-params params))) (result-type (cdr (assoc :result-type params))) + (return-val (when (and (eq result-type 'value) (not session)) + (cdr (assoc :return params)))) (full-body (org-babel-expand-body:generic - body params (org-babel-variable-assignments:python params))) + (concat body (if return-val (format "return %s" return-val) "")) + params (org-babel-variable-assignments:python params))) (result (org-babel-python-evaluate session full-body result-type result-params))) (or (cdr (assoc :file params)) |