From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: babel python example not reproducible Date: Thu, 19 Jun 2014 09:40:34 -0400 Message-ID: <874mzh10a8.fsf@gmail.com> References: <87egyox566.fsf@gmail.com> <87egym2cnn.fsf@gmail.com> <53A27BD6.5060007@easy-emacs.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wxcek-0002n0-Vf for emacs-orgmode@gnu.org; Thu, 19 Jun 2014 09:45:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wxcec-0007P8-AV for emacs-orgmode@gnu.org; Thu, 19 Jun 2014 09:45:34 -0400 Received: from mail-qg0-x22a.google.com ([2607:f8b0:400d:c04::22a]:35114) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wxcec-0007Oq-5b for emacs-orgmode@gnu.org; Thu, 19 Jun 2014 09:45:26 -0400 Received: by mail-qg0-f42.google.com with SMTP id e89so2131484qgf.15 for ; Thu, 19 Jun 2014 06:45:25 -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: Andreas =?utf-8?Q?R=C3=B6hler?= Cc: emacs-orgmode@gnu.org, Eric Schulte Andreas R=C3=B6hler writes: > On 18.06.2014 15:59, Eric Schulte wrote: >> Shiyuan writes: >> >>> Hi all, >>> I found a solution to fix the echo problem of the emacs python s= hell: >>> http://stackoverflow.com/questions/8060609/python-interpreter-in-emacs-= repeats-lines >>> >>> That is, in the Interior Python buffer, do >>> M-: (setq comint-process-echoes t) ;; or nil >>> >>> Now, if I enter command directly in the interior python buffer, the com= mand >>> is not echoed and this is what I want. >>> >>> However, When I evaluate the python src code block in org-mode(by `C-c >>> C-c`), the problem persists. I notice every time I evaluate the block, I >>> see 'org_babel_python_eoe' in the interior python buffer. >>> >>> I stumbled on a very strange emacs behavior. When I fiddled around, at >>> some point, I produced the correct answer as the manual. I thought I got >>> the right setup, but when I saved everything and restarted emacs, probl= em >>> persists. Will it be a sign of anything wrong? >>> >>> What's even stranger is that: the evaluation for the first time gives >>> different results from the evaluation for the second time, on exactly = the >>> same src_block: >>> >>> This is what I got when I evaluation the code block for the first time: >>> ------------------------------------- >>> #+BEGIN_SRC python :results output :session foo >>> x=3D100 >>> print "hello" >>> 2 >>> print "bye" >>> #+END_SRC >>> >>> #+RESULTS: >>> #+begin_example >>> >>> x=3D100 >>>>>> print "hello" >>>>>> hello >>> 2 >>> 2 >>> print "bye" >>> bye >>> >>> >>> #+end_example >>> ----------------------------------------------- >>> ------------------------------------------------------- >>> >>> The following is what I got when I evaluate the same block again: >>> #+BEGIN_SRC python :results output :session foo >>> x=3D100 >>> print "hello" >>> 2 >>> print "bye" >>> #+END_SRC >>> >>> #+RESULTS: >>> : x=3D100 >>> : print "hello" >>> : hello >>> : 2 >>> : 2 >>> : print "bye" >>> : bye >>> : >>> : >>> >>> Notice that the prompt symbol ">>>" is in the result for the first >>> evaluation but not in the second evaluation. >> >> This issue has been raised before, it is a quirk of how the python >> session starts up. I think we've done what we can to handle this on the >> Org-mode side, I'd ask for a fix on the python.el maintainers. > > > The prompts appear as respond from Python-process when setup-code is sent= at the beginning. > org-babel already knows how to fetch only the results from last prompt. > Probably separating a first run-python/py-shell from execute-process woul= d do it. > I don't follow the above with sufficient clarity to implement your suggestion. Could you provide a patch to the `org-babel-python-initiate-session-by-key' function? Thanks, Eric > > Best, > > Andreas --=20 Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D (see https://u.fsf.org/yw)