From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: org-babel -- Improper syntax error in session mode? Date: Sun, 19 Jun 2011 23:17:29 -0400 Message-ID: <23747.1308539849@alphaville.dokosmarshall.org> References: <87k4chwgpa.fsf@gmail.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:41750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYUzv-0001u1-Ve for emacs-orgmode@gnu.org; Sun, 19 Jun 2011 23:18:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYUzu-0005AB-Tu for emacs-orgmode@gnu.org; Sun, 19 Jun 2011 23:17:59 -0400 Received: from vms173003pub.verizon.net ([206.46.173.3]:43854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYUzu-00059z-QA for emacs-orgmode@gnu.org; Sun, 19 Jun 2011 23:17:58 -0400 Received: from alphaville.dokosmarshall.org ([unknown] [173.76.32.106]) by vms173003.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0LN2006CLJT5RB20@vms173003.mailsrvcs.net> for emacs-orgmode@gnu.org; Sun, 19 Jun 2011 22:17:35 -0500 (CDT) In-reply-to: Message from Herbert Sitz of "Mon, 20 Jun 2011 02:12:32 -0000." 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: Herbert Sitz Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Herbert Sitz wrote: > Eric Schulte gmail.com> writes: > > I can confirm that I see the same behavior. Also, if I manually type > > the body of the code block into the session I get the same error output > > from Python, so I don't believe this is due to a problem with Babel. > > > > It appears the problem is that the python session is interactive and is built to > emit output after each Python "block" (e.g., the 'for' block), before another > "block" of Python is entered. If this is the way it's designed then it seems to > me that it's Babel's obligation to feed the Python blocks to the Python session > as required and then assemble the output pieces as appropriate. Or am I missing > something? -- Herb > Having babel recognize python blocks in order to feed them to the python interpreter as complete blocks seems a bit too much to me. Of course, what I think matters little: it's what Eric thinks that matters here. Having said that, however, I think there *is* a problem: If you just start the python interpreter and start typing into it: --8<---------------cut here---------------start------------->8--- x = 1 for i in range(1,5): x = x + i print x print "Did it work?" --8<---------------cut here---------------end--------------->8--- the problem becomes obvious: the interpreter is still in "indented mode" and complains about the last print, because it is not "properly" indented. OTOH, if you exit "indented mode" by pressing another RET before the final print, the interpreter is happy. This is a kludge used by the interactive interpreter to accommodate python's reliance on indentation to delimit block structure. That however does not work with babel: even if I leave empty lines between the print x and the last print, the error persists. Apparently, babel does not send the empty lines to the interpreter. If there is a bug in babel, it seems to me this is it. Nick