From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [babel] python sessions Date: Sun, 03 Jul 2011 09:15:59 -0600 Message-ID: <87r5671jbz.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:53916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdOTz-0000IE-UK for emacs-orgmode@gnu.org; Sun, 03 Jul 2011 11:21:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QdOTx-0006WM-N5 for emacs-orgmode@gnu.org; Sun, 03 Jul 2011 11:21:15 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:37832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdOTw-0006WF-Uz for emacs-orgmode@gnu.org; Sun, 03 Jul 2011 11:21:13 -0400 Received: by pvc12 with SMTP id 12so4972444pvc.0 for ; Sun, 03 Jul 2011 08:21:11 -0700 (PDT) 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: Andrea Crotti Cc: Org mode Hi Andrea, Andrea Crotti writes: > I wanted to use sessions in python to do some nice literate programming > and splitting functions, but it doesn't work as expected. > > Here below a very simple example in python and ruby, where in ruby > everything seems to work well while in python it doesn't... > And by the way, what is that org_babel_python_eoe? I can't find it > documented anywhere in the manual... > This string is used by Babel to indicate when to stop waiting for output form the interactive python process and return control to the user. > > I've read some time ago that python support for babel was a bit tricky, > are there workarounds to make it work anyway? > This is true, in addition to being a language which is dependent upon whitespace characters, python has been tricky due to the many independent inferior python modes (python.el, python-mode.el, etc...) and to the fact that I personally and not very familiar with the language. I've just pushed up a patch which should improve upon the python session behavior. After this patch your example returns the following results... --8<---------------cut here---------------start------------->8--- #+begin_src python :session :results silent def var(x): return float(x ** 2) #+end_src #+begin_src python :session :result value def var2(x): return x ** 2 * var(x) var2(10) #+end_src #+results: : 10000.0 --8<---------------cut here---------------end--------------->8--- Please let me know if you notice any other problematic behavior. Thanks -- Eric -- Eric Schulte http://cs.unm.edu/~eschulte/