From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gary Oberbrunner Subject: Re: python sessions Date: Tue, 26 Mar 2013 17:41:31 -0400 Message-ID: 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> <5150B790.2040603@easy-emacs.de> <87boa7upoc.fsf@gmail.com> <51514059.1020902@easy-emacs.de> <87li9a72vn.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8ff1c61ce368b304d8dac85f Return-path: Received: from eggs.gnu.org ([208.118.235.92]:55533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKbcc-0004ky-Ae for emacs-orgmode@gnu.org; Tue, 26 Mar 2013 17:41:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKbcb-0003CE-22 for emacs-orgmode@gnu.org; Tue, 26 Mar 2013 17:41:34 -0400 Received: from mail-ob0-x235.google.com ([2607:f8b0:4003:c01::235]:56398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKbca-0003C9-TK for emacs-orgmode@gnu.org; Tue, 26 Mar 2013 17:41:32 -0400 Received: by mail-ob0-f181.google.com with SMTP id ni5so7554243obc.26 for ; Tue, 26 Mar 2013 14:41:31 -0700 (PDT) In-Reply-To: <87li9a72vn.fsf@gmail.com> 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: emacs-orgmode --e89a8ff1c61ce368b304d8dac85f Content-Type: text/plain; charset=ISO-8859-1 I did some further testing. With my patch, my real org-mode python file is now actually working. There were a few gotchas I didn't understand about session mode and python and matplotlib: 1. In session mode, you are essentially running an interactive python. (This is made explicit by my patch, which passes -i). 2. In interactive mode, blank lines are special: they indicate the end of an indented block. So you have to write your org-mode python a little differently when using session mode. 3. matplotlib uses an "interactive" backend when started from an interactive python (sensibly). So you have to set the backend explicitly when using session mode, or it hangs forever with no indication what's wrong. 4. ob-python does not handle python errors at all in session mode: it ignores them silently. This makes it really hard to debug the python code. I'd like to document #s 1-3; where should that go? I'd like to work on a patch for #4; it seems like the only thing is to search in the session buffer for likely error strings. Is there any better method anyone can think of? -- Gary --e89a8ff1c61ce368b304d8dac85f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I did some further testing. =A0With my patch, my real org-= mode python file is now actually working. =A0There were a few gotchas I did= n't understand about session mode and python and matplotlib:

1. In session mode, you are essentially running an interactive p= ython. =A0(This is made explicit by my patch, which passes -i).
2. In interactive mode, blank lines are special: they indicate the end= of an indented block. =A0So you have to write your org-mode python a littl= e differently when using session mode.
3. matplotlib uses an "interactive" backend when start= ed from an interactive python (sensibly). =A0So you have to set the backend= explicitly when using session mode, or it hangs forever with no indication= what's wrong.
4. ob-python does not handle python errors at all in session mod= e: it ignores them silently. =A0This makes it really hard to debug the pyth= on code.

I'd like to document #s 1-3; where should that go?
I'd like to w= ork on a patch for #4; it seems like the only thing is to search in the ses= sion buffer for likely error strings. =A0Is there any better method anyone = can think of?

--
Gary
--e89a8ff1c61ce368b304d8dac85f--