Nick Dokos writes: > 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: > > x = 1 > for i in range(1,5): > x = x + i > print x > print "Did it work?" > > 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 > > -- Eric Schulte http://cs.unm.edu/~eschulte/