From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-15?Q?Andreas_R=F6hler?= Subject: Re: python sessions Date: Mon, 25 Mar 2013 21:46:08 +0100 Message-ID: <5150B790.2040603@easy-emacs.de> References: <51496061.20706@easy-emacs.de> <514AB9FC.3050601@easy-emacs.de> <87d2ut2o5m.fsf@bzg.ath.cx> <514AC116.7030408@easy-emacs.de> <877gkxrbgn.fsf@gmail.com> <514EAF96.3030402@easy-emacs.de> <17915.1364144298@alphaville> <18546.1364150504@alphaville> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:50430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKEGV-0007W2-9V for emacs-orgmode@gnu.org; Mon, 25 Mar 2013 16:45:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKEGP-0006Tz-Qf for emacs-orgmode@gnu.org; Mon, 25 Mar 2013 16:45:11 -0400 Received: from moutng.kundenserver.de ([212.227.17.9]:53952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKEGP-0006Rz-Hw for emacs-orgmode@gnu.org; Mon, 25 Mar 2013 16:45:05 -0400 In-Reply-To: <18546.1364150504@alphaville> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: nicholas.dokos@hp.com Cc: Ivan Andrus , Bastien , emacs-orgmode , Eric Schulte Am 24.03.2013 19:41, schrieb Nick Dokos: >>> running into this, func def seems missing: Debugger entered--Lisp error: (void-function org-babel-result-cond) (org-babel-result-cond result-params results (org-babel-python-table-or-string results)) (if (string= (substring org-babel-python-eoe-indicator 1 -1) results) nil (org-babel-result-cond result-params results (org-babel-python-table-or-string results))) (unless (string= (substring org-babel-python-eoe-indicator 1 -1) results) (org-babel-result-cond result-params results (org-babel-python-table-or-string results))) (lambda (results) (unless (string= (substring org-babel-python-eoe-indicator 1 -1) results) (org-babel-result-cond result-params results (org-babel-python-table-or-string results))))("Traceback (most recent call last):\n File \"\", line 1, in \nNameError: name 'foo' is not defined\nbye") (let* ((send-wait (lambda nil (comint-send-input nil t) (sleep-for 0 5))) (dump-last-value (lambda (tmp-file pp) (mapc (lambda (statement) (insert statement) (funcall send-wait)) (if pp (list "import pprint" (format "open('%s', 'w').write(pprint.pformat(_))" ...)) (list (format "open('%s', 'w').write(str(_))" ...)))))) (input-body (lambda (body) (mapc (lambda (line) (insert line) (funcall send-wait)) (split-string body "[ \n]")) (funcall send-wait)))) ((lambda (results) (unless (string= (substring org-babel-python-eoe-indicator 1 -1) results) (org-babel-result-cond result-params results (org-babel-python-table-or-string results)))) (case result-type (output (mapconcat (function org-babel-trim) (butlast (org-babel-comint-with-output (session org-babel-python-eoe-indicator t body) (funcall input-body body) (funcall send-wait) (funcall send-wait) (insert org-babel-python-eoe-indicator) (funcall send-wait)) 2) "\n")) (value (let ((tmp-file (org-babel-temp-file "python-"))) (org-babel-comint-with-output (session org-babel-python-eoe-indicator nil body) (let (...) (funcall input-body body) (funcall dump-last-value tmp-file ...) (funcall send-wait) (funcall send-wait) (insert org-babel-python-eoe-indicator) (funcall send-wait))) (org-babel-eval-read-file tmp-file)))))) org-babel-python-evaluate-session(# "print(foo(100)) \nprint \"bye\"" output ("output" "replace")) (if session (org-babel-python-evaluate-session session body result-type result-params) (org-babel-python-evaluate-external-process body result-type result-params preamble)) org-babel-python-evaluate(# "print(foo(100)) \nprint \"bye\"" output ("output" "replace") nil) (let* ((session (org-babel-python-initiate-session (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 (quote value)) (not session)) (cdr (assoc :return params)))) (preamble (cdr (assoc :preamble params))) (full-body (org-babel-expand-body:generic (concat body (if return-val (format "\nreturn %s" return-val) "")) params (org-babel-variable-assignments:python params))) (result (org-babel-python-evaluate session full-body result-type result-params preamble))) (org-babel-reassemble-table result (org-babel-pick-name (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) (org-babel-pick-name (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))) org-babel-execute:python("print(foo(100)) \nprint \"bye\"" ((:comments . #1="") (:shebang . #1#) (:cache . "no") (:padline . #1#) (:noweb . "no") (:tangle . "no") (:exports . "results") (:results . "replace output") (:hlines . "no") (:padnewline . "yes") (:session) (:result-type . output) (:result-params "output" "replace") (:rowname-names) (:colname-names))) org-babel-execute-src-block(nil ("python" "print(foo(100)) \nprint \"bye\"" ((:comments . #1="") (:shebang . #1#) (:cache . "no") (:padline . #1#) (:noweb . "no") (:tangle . "no") (:exports . "results") (:results . "replace output") (:hlines . "no") (:padnewline . "yes") (:session) (:result-type . output) (:result-params "output" "replace") (:rowname-names) (:colname-names)) "" nil 0)) org-babel-execute-src-block-maybe() org-babel-execute-maybe() org-babel-execute-safely-maybe() run-hook-with-args-until-success(org-babel-execute-safely-maybe) org-ctrl-c-ctrl-c(nil) call-interactively(org-ctrl-c-ctrl-c nil nil)