From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: Buffer-wide definitions in org-babel Date: Thu, 08 Oct 2009 10:11:02 -0400 Message-ID: <87fx9u7z7t.fsf@stats.ox.ac.uk> References: <55bd243d0910070720i3085af58xc30cf14011d6375a@mail.gmail.com> <55bd243d0910080222q34a7ac79g26a7f9358d806e62@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mvti5-0001dr-9J for emacs-orgmode@gnu.org; Thu, 08 Oct 2009 10:11:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mvti0-0001cX-Ia for emacs-orgmode@gnu.org; Thu, 08 Oct 2009 10:11:12 -0400 Received: from [199.232.76.173] (port=45272 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mvti0-0001cR-8h for emacs-orgmode@gnu.org; Thu, 08 Oct 2009 10:11:08 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:34452) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mvthz-0004RC-ED for emacs-orgmode@gnu.org; Thu, 08 Oct 2009 10:11:07 -0400 In-Reply-To: <55bd243d0910080222q34a7ac79g26a7f9358d806e62@mail.gmail.com> (Juan Reyero's message of "Thu, 8 Oct 2009 11:22:58 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Juan Reyero Cc: emacs-orgmode@gnu.org Juan Reyero writes: [...] >> --8<---------------cut here---------------start------------->8--- >> ** persistent python >> #+begin_src python :session :results silent >> =C2=A0import types >> #+end_src >> >> #+begin_src python :session >> =C2=A0types.FunctionType >> #+end_src >> >> #+resname: >> : function >> --8<---------------cut here---------------end--------------->8--- > > This works, but see what happens with this (no previous src chunks): > > #+begin_src python :session :results output > 2 > #+end_src > > #+resname: > : 2 > : 2 Hi Juan, Thanks for the org-babel suggestions. However I can't replicate this behaviour under linux. I get #+resname: : 2 for all three examples. > > (expected nothing, which is what I get if I remove the :session). An understandable expectation. In non-session mode, we collect stdout and if the expression "2" is passed to the interpreter nothing is output to stdout. However in session mode we collect whatever output appears in the comint buffer, and if you give the interpreter "2" the interpreter comes back and prints the value of that expression. I'm using org-version 6.31trans in emacs-version 23.0.91.1 under ubuntu jaunty with python 2.6.2. Is this definitely replicable under OSX? Dan > > #+begin_src python :session :results value > 2 > #+end_src > > #+resname: > : 0 > > This is how my python buffer looks like after processing this last > chunk in a fresh session: > >>>> import emacs; print '_emacs_out ()' > /Applications/Emacs.app/Contents/Resources/etc/emacs.py:24: > DeprecationWarning: the sets module is deprecated > from sets import Set > 2 > > > _ > 'org_babel_python_eoe' > 2 > 2 >>>> >>>> >>>> _ > 2 >>>> 'org_babel_python_eoe' > 'org_babel_python_eoe' >>>> >>> 2 _ 'org_babel_python_eoe' 2 >>> >>> >>> 2 >>> 'org_babel_python_eoe' >>>=20 > > But, interestingly, if I return a string instead of a number, as you > do in your example, it works: > > #+begin_src python :session :results value > "2" > #+end_src > > #+resname: > : 2 > > It is not related to a previous chunk messing up the python > interpreter. I have moved to the git version, and it still behaves > like this. I am using python 2.6.1.