From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shiyuan Subject: babel python example not reproducible Date: Tue, 10 Jun 2014 22:11:32 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7bdc853c4f115f04fb887a9a Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wuaow-0002i8-T5 for emacs-orgmode@gnu.org; Wed, 11 Jun 2014 01:11:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wuaow-0004h4-02 for emacs-orgmode@gnu.org; Wed, 11 Jun 2014 01:11:34 -0400 Received: from mail-ve0-x229.google.com ([2607:f8b0:400c:c01::229]:43620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wuaov-0004gx-R0 for emacs-orgmode@gnu.org; Wed, 11 Jun 2014 01:11:33 -0400 Received: by mail-ve0-f169.google.com with SMTP id pa12so3565783veb.28 for ; Tue, 10 Jun 2014 22:11:33 -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: emacs-orgmode@gnu.org --047d7bdc853c4f115f04fb887a9a Content-Type: text/plain; charset=UTF-8 Hi, I try to understand the difference of "session" and "non-session" as in http://orgmode.org/manual/Results-of-evaluation.html#Results-of-evaluation However, I copy-paste the example but have different result. It looks like that the result contains whatever sent to the interactive shell too. Any option I need to set to reproduce the same result as in the manual? I am using python 2.7.5 + emacs 24.3.9 + orgmode 8.2.6. #+BEGIN_SRC python :results output :session print "hello" 2 print "bye" #+END_SRC #+RESULTS: : print "hello" : hello : 2 : 2 : print "bye" : bye : : --047d7bdc853c4f115f04fb887a9a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,=C2=A0
=C2=A0 =C2=A0 =C2=A0I try to understand the = difference of "session" and "non-session" as in =C2=A0http://orgmode.org/manual/Results-of-evaluation.html#Results-of-= evaluation

However, I copy-paste the example but have different re= sult. It looks like that the result contains whatever sent to the interacti= ve shell too. Any option I need to set to reproduce the same result as in t= he manual? =C2=A0I am using python 2.7.5 + emacs 24.3.9 + orgmode 8.2.6.=C2= =A0

#+BEGIN_SRC python :results output :session
<= div>=C2=A0print "hello"
=C2=A02
=C2=A0print &= quot;bye"
#+END_SRC

#+RESULTS:
: print "hello"
: hello
: 2
: 2
: print "bye"<= /div>
: bye
:=C2=A0
:=C2=A0

--047d7bdc853c4f115f04fb887a9a-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: mdoyley@ur.rochester.edu (Doyley, Marvin) Subject: Re: babel python example not reproducible Date: Wed, 11 Jun 2014 03:48:36 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuhfW-000447-W3 for emacs-orgmode@gnu.org; Wed, 11 Jun 2014 08:30:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuhfP-0006Vu-H4 for emacs-orgmode@gnu.org; Wed, 11 Jun 2014 08:30:18 -0400 Received: from plane.gmane.org ([80.91.229.3]:53015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuhfP-0006Vl-BZ for emacs-orgmode@gnu.org; Wed, 11 Jun 2014 08:30:11 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WuhfI-0004m2-23 for emacs-orgmode@gnu.org; Wed, 11 Jun 2014 14:30:04 +0200 Received: from cpe-66-66-94-63.rochester.res.rr.com ([66.66.94.63]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Jun 2014 14:30:04 +0200 Received: from mdoyley by cpe-66-66-94-63.rochester.res.rr.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Jun 2014 14:30:04 +0200 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: emacs-orgmode@gnu.org Works for me, see example below #+BEGIN_SRC python :results output :session foo x=100 print "hello" 2 print "bye" #+END_SRC #+RESULTS: : : >>> hello : 2 : bye #+BEGIN_SRC python :results output :session foo print "hello good bye" print "Printing value from previous session", x #+END_SRC #+RESULTS: : : hello good bye : Printing value from previous session 100 The only difference is that I like to give my session a name and for what it is worth I am using ipython (don't think this will make a difference). You can do this including the following statement in your .emacs file (setq python-shell-interpreter "ipython") (setq python-shell-interpreter-args "--pylab") Hope this help. Cheers, M From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shiyuan Subject: Re: babel python example not reproducible Date: Sun, 15 Jun 2014 22:59:26 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7bdc853cce12c904fbedba17 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwPx3-00040t-6o for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 01:59:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwPx2-0000km-2s for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 01:59:29 -0400 Received: from mail-vc0-x236.google.com ([2607:f8b0:400c:c03::236]:49426) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwPx1-0000kh-Tk for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 01:59:28 -0400 Received: by mail-vc0-f182.google.com with SMTP id il7so4478242vcb.13 for ; Sun, 15 Jun 2014 22:59:26 -0700 (PDT) In-Reply-To: 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: "Doyley, Marvin" Cc: emacs-orgmode@gnu.org --047d7bdc853cce12c904fbedba17 Content-Type: text/plain; charset=UTF-8 The two setting doesn't seem to have effect. (setq python-shell-interpreter "ipython") (setq python-shell-interpreter-args "--pylab") When I did `C-c C-c` on the SRC block to execute the code, emacs created a buffer with the interior python process. When I switched to the process, I saw it is python 2.5.3, not ipython. Also, it looks like the problem is with the shell interpreter. If I enter command directly in the shell buffer, the shell buffer will echo command itself and then the result. >>> print "Hello" print "Hello" Hello. Is there any setting to control this shell behavior? Can I make the python shell not echo the command? Thanks. On Wed, Jun 11, 2014 at 12:48 AM, Doyley, Marvin wrote: > Works for me, see example below > #+BEGIN_SRC python :results output :session foo > > x=100 > print "hello" > 2 > print "bye" > #+END_SRC > > #+RESULTS: > : > : >>> hello > : 2 > : bye > > #+BEGIN_SRC python :results output :session foo > > print "hello good bye" > print "Printing value from previous session", x > #+END_SRC > > #+RESULTS: > : > : hello good bye > : Printing value from previous session 100 > > The only difference is that I like to give my session a name and for > what it is worth I am using ipython (don't think this will make a > difference). You can do this including the > following statement in your .emacs file > > (setq python-shell-interpreter "ipython") > (setq python-shell-interpreter-args "--pylab") > > Hope this help. > Cheers, > M > > > --047d7bdc853cce12c904fbedba17 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
The two setting doesn't seem to have effect. =C2= =A0
(setq python-shell-interpreter "ipython")
(setq pytho= n-shell-interpreter-args "--pylab")
Whe= n I did `C-c C-c` on the SRC block to execute the code, emacs created a buf= fer with the interior python process. When I switched to the process, I saw= it is python 2.5.3, not ipython. =C2=A0

Also, it lo= oks like the problem is with the shell interpreter. If I enter command dire= ctly in the shell buffer, the shell buffer will echo command itself and the= n the result.=C2=A0

>>>= ; print "Hello"
print "Hello= "
Hello.=C2=A0

Is there any setting to control this shell= behavior? Can I make the python shell not echo the command? Thanks. =C2=A0=


On Wed,= Jun 11, 2014 at 12:48 AM, Doyley, Marvin <mdoyley@ur.rochester.edu= > wrote:
Works for me, see example below
#+BEGIN_SRC python :results output :session foo

x=3D100
print "hello"
2
print "bye"
#+END_SRC

#+RESULTS:
:
: >>> hello
: 2
: bye

#+BEGIN_SRC python :results output :session foo

print "hello good bye"
print "Printing value from previous session", x
#+END_SRC

#+RESULTS:
:
: hello good bye
: Printing value from previous session 100

The only difference is that I like to give my session a name and for
what it is worth I am using ipython (don't think this will make a diffe= rence). You can do this including the
following statement in your .emacs file

(setq python-shell-interpreter "ipython")
(setq python-shell-interpreter-args "--pylab")

Hope this help.
Cheers,
M



--047d7bdc853cce12c904fbedba17-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: babel python example not reproducible Date: Mon, 16 Jun 2014 08:19:50 -0400 Message-ID: <87k38hf3mh.fsf@alphaville.bos.redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwVtZ-00081K-OY for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 08:20:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwVtS-0004qk-9c for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 08:20:17 -0400 Received: from plane.gmane.org ([80.91.229.3]:40006) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwVtS-0004qT-3f for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 08:20:10 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WwVtK-0001Rj-Q3 for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 14:20:02 +0200 Received: from pool-98-110-160-12.bstnma.fios.verizon.net ([98.110.160.12]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 Jun 2014 14:20:02 +0200 Received: from ndokos by pool-98-110-160-12.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 Jun 2014 14:20:02 +0200 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: emacs-orgmode@gnu.org Shiyuan writes: > The two setting doesn't seem to have effect.   > (setq python-shell-interpreter "ipython") > (setq python-shell-interpreter-args "--pylab") > > When I did `C-c C-c` on the SRC block to execute the code, emacs > created a buffer with the interior python process. When I switched to > the process, I saw it is python 2.5.3, not ipython.   > > Also, it looks like the problem is with the shell interpreter. If I > enter command directly in the shell buffer, the shell buffer will echo > command itself and then the result.  > >>>> print "Hello" > print "Hello" > Hello.  > > Is there any setting to control this shell behavior? Can I make the > python shell not echo the command? Thanks.   > When a *shell* does that to me, I do (on Linux) $ stty -echo but I'm not sure where that would fit into your setup. Nick From mboxrd@z Thu Jan 1 00:00:00 1970 From: mdoyley@ur.rochester.edu (Doyley, Marvin) Subject: Re: babel python example not reproducible Date: Mon, 16 Jun 2014 10:35:33 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwY12-0005Kh-6K for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 10:36:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwY0t-00035p-QP for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 10:36:08 -0400 Received: from plane.gmane.org ([80.91.229.3]:59358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwY0t-00035g-KN for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 10:35:59 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WwY0k-0001YE-29 for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 16:35:50 +0200 Received: from davinci.ece.rochester.edu ([128.151.164.248]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 Jun 2014 16:35:50 +0200 Received: from mdoyley by davinci.ece.rochester.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 Jun 2014 16:35:50 +0200 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: emacs-orgmode@gnu.org Hi Shiyuan, I think the problem is that Emacs or babel is using python located in /usr/bin or /usr/local/sbin rather than default python or ipython. The way I got around this is rename python in these locations to python_old and then did a soft link to ipython (i.e., ln -s /anaconda/bin/ipython python). I am sure there is a smarter way of telling babel to use ipython, but this was my work around. Hope this help cheers, M From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: babel python example not reproducible Date: Mon, 16 Jun 2014 11:03:36 -0400 Message-ID: <87egyox566.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwYYC-0004be-J0 for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 11:10:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwYY7-00085m-EI for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 11:10:24 -0400 Received: from mail-oa0-f42.google.com ([209.85.219.42]:47777) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwYY7-00085W-AI for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 11:10:19 -0400 Received: by mail-oa0-f42.google.com with SMTP id eb12so6019883oac.1 for ; Mon, 16 Jun 2014 08:09:42 -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: "Doyley, Marvin" Cc: emacs-orgmode@gnu.org mdoyley@ur.rochester.edu (Doyley, Marvin) writes: > Hi Shiyuan, > > I think the problem is that Emacs or babel is using python located in > /usr/bin or /usr/local/sbin rather than default python or ipython. The way I got > around this is rename python in these locations to python_old and then did > a soft link to ipython (i.e., ln -s /anaconda/bin/ipython python). > > I am sure there is a smarter way of telling babel to use ipython, but > this was my work around. > See the `org-babel-python-command' variable. > > Hope this help > cheers, > M > > > > -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D (see https://u.fsf.org/yw) From mboxrd@z Thu Jan 1 00:00:00 1970 From: mdoyley@ur.rochester.edu (Doyley, Marvin) Subject: Re: babel python example not reproducible Date: Mon, 16 Jun 2014 12:12:54 -0400 Message-ID: References: <87egyox566.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwZYz-0005p7-45 for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 12:15:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwZYr-0008Sj-MQ for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 12:15:17 -0400 Received: from plane.gmane.org ([80.91.229.3]:34438) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwZYr-0008Sb-GX for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 12:15:09 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WwZYl-0003P0-T0 for emacs-orgmode@gnu.org; Mon, 16 Jun 2014 18:15:03 +0200 Received: from davinci.ece.rochester.edu ([128.151.164.248]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 Jun 2014 18:15:03 +0200 Received: from mdoyley by davinci.ece.rochester.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 Jun 2014 18:15:03 +0200 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: emacs-orgmode@gnu.org Hi Eric, Thanks for showing me the smart way of doing this. cheers, M -- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shiyuan Subject: Re: babel python example not reproducible Date: Mon, 16 Jun 2014 23:21:30 -0700 Message-ID: References: <87egyox566.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c2081090deee04fc02271d Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwmlz-0002tL-4z for emacs-orgmode@gnu.org; Tue, 17 Jun 2014 02:21:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wwmlv-0002sO-Rp for emacs-orgmode@gnu.org; Tue, 17 Jun 2014 02:21:35 -0400 Received: from mail-ve0-x231.google.com ([2607:f8b0:400c:c01::231]:39087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwmlv-0002s8-Mn for emacs-orgmode@gnu.org; Tue, 17 Jun 2014 02:21:31 -0400 Received: by mail-ve0-f177.google.com with SMTP id i13so3443807veh.22 for ; Mon, 16 Jun 2014 23:21:30 -0700 (PDT) In-Reply-To: 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: "Doyley, Marvin" Cc: emacs-orgmode@gnu.org --001a11c2081090deee04fc02271d Content-Type: text/plain; charset=UTF-8 Hi all, I found a solution to fix the echo problem of the emacs python shell: 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 command 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, problem 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=100 print "hello" 2 print "bye" #+END_SRC #+RESULTS: #+begin_example x=100 >>> 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=100 print "hello" 2 print "bye" #+END_SRC #+RESULTS: : x=100 : 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. Also the result is not embedded in the #+being_example/#+end_example for the second evaluation. I want to hunt down the problem. Any hints/helps is greatly appreciated. Shiyuan On Mon, Jun 16, 2014 at 9:12 AM, Doyley, Marvin wrote: > Hi Eric, > > Thanks for showing me the smart way of doing this. > > cheers, > M > -- > > > > --001a11c2081090deee04fc02271d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi all,=C2=A0
=C2=A0 =C2=A0 =C2=A0 I found a solution = to fix the echo problem of the emacs python shell:=C2=A0http://stackoverflow.com/questions/8060609/python-inte= rpreter-in-emacs-repeats-lines

That is, in the Interior Python buffer, do=C2=A0
<= div>M-: (set= q comint-process-echoes t) ;; or nil

Now, if I enter command directly in the interior python= buffer, the command is not echoed and this is what I want.=C2=A0

However, When I evaluate the python src code block in org-m= ode(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.= =C2=A0

I =C2=A0stumbled on a very strange emacs behavior. When= I fiddled around, at some point, I produced the correct answer as the manu= al. I thought I got the right setup, but when I saved everything and restar= ted emacs, problem persists. Will it be a sign of anything wrong?=C2=A0

What's even stranger is that: the evaluation for th= e first time gives different results from the evaluation for the second tim= e, =C2=A0on exactly the same src_block:=C2=A0

This= is what I got when I evaluation the code block for the first time:=C2=A0
-------------------------------------
#+BEGIN_SRC pytho= n :results output :session foo
x=3D100
print "hell= o"
2
print "bye"
#+END_SRC

#+RESULTS:
#+begin_example

x=3D100
>>> print "hello"
>= ;>> hello
2
2
print "bye"
bye


#+end_example
<= div>-----------------------------------------------
-------------= ------------------------------------------

The fol= lowing is what I got when I evaluate the same block again:=C2=A0
#+BEGIN_SRC python :results output :session foo
x=3D100=
print "hello"
2
print "bye&qu= ot;
#+END_SRC

#+RESULTS:
: x= =3D100
: print "hello"
: hello
: 2
: = 2
: print "bye"
: bye
:=C2=A0
=
:=C2=A0

Notice that the prompt symbol &= quot;>>>" is in the result for the first evaluation but not i= n the second evaluation. =C2=A0Also the result is not embedded in the #+bei= ng_example/#+end_example for the second evaluation.=C2=A0

I want to hunt down the problem. Any hints/helps is gre= atly appreciated.=C2=A0

Shiyuan=C2=A0



On Mon, Jun 16, 2014 at 9:12 AM, Doyley, Marvin <mdoyley@ur.rochest= er.edu> wrote:
Hi Eric,

Thanks for showing me the smart way of doing this.

cheers,
M
--




--001a11c2081090deee04fc02271d-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?QW5kcmVhcyBSw7ZobGVy?= Subject: Re: babel python example not reproducible Date: Tue, 17 Jun 2014 13:54:37 +0200 Message-ID: <53A02C7D.4020202@easy-emacs.de> References: <87egyox566.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwryv-0004g7-PE for emacs-orgmode@gnu.org; Tue, 17 Jun 2014 07:55:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wwryn-0001h9-Eg for emacs-orgmode@gnu.org; Tue, 17 Jun 2014 07:55:17 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:52564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwryn-0001ga-6C for emacs-orgmode@gnu.org; Tue, 17 Jun 2014 07:55:09 -0400 In-Reply-To: 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: emacs-orgmode@gnu.org On 17.06.2014 08:21, Shiyuan wrote: > Hi all, > I found a solution to fix the echo problem of the emacs python shell: > 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 command > 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, problem > 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=100 > print "hello" > 2 > print "bye" > #+END_SRC > > #+RESULTS: > #+begin_example > > x=100 >>>> 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=100 > print "hello" > 2 > print "bye" > #+END_SRC > > #+RESULTS: > : x=100 > : 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. Also the result is not > embedded in the #+being_example/#+end_example for the second evaluation. > > I want to hunt down the problem. Any hints/helps is greatly appreciated. > > Shiyuan > > Hi Guys, please permit a comment after some times - it's just not to create heroes :) IMHO the complexity orb-babel took by creating its own slots for symbols like function names, variables etc. is not to handle reliably across the languages. A net and simple way out would be just to employ commands delivered by existing Emacs modes on org-source sections. Inserting the results might be provided by a hook. Cheers, Andreas From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: babel python example not reproducible Date: Wed, 18 Jun 2014 10:02:38 -0400 Message-ID: <878uou2cn3.fsf@gmail.com> References: <87egyox566.fsf@gmail.com> <53A02C7D.4020202@easy-emacs.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxMLt-0002fe-Rf for emacs-orgmode@gnu.org; Wed, 18 Jun 2014 16:21:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxMLn-0002Gb-Ow for emacs-orgmode@gnu.org; Wed, 18 Jun 2014 16:21:01 -0400 Received: from mail-qa0-x22a.google.com ([2607:f8b0:400d:c00::22a]:48462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxMLn-0002GU-KP for emacs-orgmode@gnu.org; Wed, 18 Jun 2014 16:20:55 -0400 Received: by mail-qa0-f42.google.com with SMTP id dc16so1190061qab.29 for ; Wed, 18 Jun 2014 13:20:55 -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 > Hi Guys, > > please permit a comment after some times - it's just not to create > heroes :) > > IMHO the complexity orb-babel took by creating its own slots for > symbols like function names, variables etc. is not to handle reliably > across the languages. > I don't understand what you mean by the above. > > A net and simple way out would be just to employ commands delivered by > existing Emacs modes on org-source sections. Inserting the results > might be provided by a hook. > This is what Org-mode does when possible, and this is why some language modes are both much simpler and much more reliable than others, e.g., because of Emacs' excellent support for common lisp ob-lisp.el is both shorter and provides higher quality support than ob-python.el. $ wc -l lisp/ob-{lisp,python}.el 111 lisp/ob-lisp.el 346 lisp/ob-python.el If I've miss-understood the above please clarify. Thanks, Eric > > Cheers, > > Andreas > > > > > -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D (see https://u.fsf.org/yw) From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: babel python example not reproducible Date: Wed, 18 Jun 2014 09:59:44 -0400 Message-ID: <87egym2cnn.fsf@gmail.com> References: <87egyox566.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxMLs-0002fd-UK for emacs-orgmode@gnu.org; Wed, 18 Jun 2014 16:21:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxMLj-0002GJ-Vt for emacs-orgmode@gnu.org; Wed, 18 Jun 2014 16:21:00 -0400 Received: from mail-qg0-x22d.google.com ([2607:f8b0:400d:c04::22d]:41222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxMLj-0002Fy-SJ for emacs-orgmode@gnu.org; Wed, 18 Jun 2014 16:20:51 -0400 Received: by mail-qg0-f45.google.com with SMTP id 63so1271021qgz.32 for ; Wed, 18 Jun 2014 13:20:50 -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: Shiyuan Cc: emacs-orgmode@gnu.org, "Doyley, Marvin" Shiyuan writes: > Hi all, > I found a solution to fix the echo problem of the emacs python shell: > 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 command > 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, problem > 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=100 > print "hello" > 2 > print "bye" > #+END_SRC > > #+RESULTS: > #+begin_example > > x=100 >>>> 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=100 > print "hello" > 2 > print "bye" > #+END_SRC > > #+RESULTS: > : x=100 > : 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. > Also the result is not embedded in the #+being_example/#+end_example > for the second evaluation. > Yes, short examples are examplized with ":" instead of the heavier weight example blocks. The results are functionally equivalent, but you can customize the size at which different methods are used by changing the `org-babel-min-lines-for-block-output' variable. > > I want to hunt down the problem. Any hints/helps is greatly appreciated. > Hope this helps. Sadly Emacs python support is sub-par and as a consumer, Org-mode python code blocks suffer. Best, > > Shiyuan > > > > > On Mon, Jun 16, 2014 at 9:12 AM, Doyley, Marvin > wrote: > >> Hi Eric, >> >> Thanks for showing me the smart way of doing this. >> >> cheers, >> M >> -- >> >> >> >> -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D (see https://u.fsf.org/yw) From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Subject: Re: babel python example not reproducible Date: Thu, 19 Jun 2014 07:57:42 +0200 Message-ID: <53A27BD6.5060007@easy-emacs.de> References: <87egyox566.fsf@gmail.com> <87egym2cnn.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxVMf-0008O1-ML for emacs-orgmode@gnu.org; Thu, 19 Jun 2014 01:58:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxVMZ-00052X-EX for emacs-orgmode@gnu.org; Thu, 19 Jun 2014 01:58:25 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:59548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxVMZ-00052R-4M for emacs-orgmode@gnu.org; Thu, 19 Jun 2014 01:58:19 -0400 In-Reply-To: <87egym2cnn.fsf@gmail.com> 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: emacs-orgmode@gnu.org, Eric Schulte 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 shell: >> 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 command >> 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, problem >> 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=100 >> print "hello" >> 2 >> print "bye" >> #+END_SRC >> >> #+RESULTS: >> #+begin_example >> >> x=100 >>>>> 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=100 >> print "hello" >> 2 >> print "bye" >> #+END_SRC >> >> #+RESULTS: >> : x=100 >> : 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 would do it. Best, Andreas 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) From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?QW5kcmVhcyBSw7ZobGVy?= Subject: Re: babel python example not reproducible Date: Fri, 20 Jun 2014 07:53:53 +0200 Message-ID: <53A3CC71.7020002@easy-emacs.de> References: <87egyox566.fsf@gmail.com> <87egym2cnn.fsf@gmail.com> <53A27BD6.5060007@easy-emacs.de> <874mzh10a8.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxrmR-0004h2-A4 for emacs-orgmode@gnu.org; Fri, 20 Jun 2014 01:54:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxrmK-0004IN-Ga for emacs-orgmode@gnu.org; Fri, 20 Jun 2014 01:54:31 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:63823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxrmE-0004Gd-S2 for emacs-orgmode@gnu.org; Fri, 20 Jun 2014 01:54:24 -0400 In-Reply-To: <874mzh10a8.fsf@gmail.com> 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: Eric Schulte Cc: emacs-orgmode@gnu.org On 19.06.2014 15:40, Eric Schulte wrote: > Andreas Röhler 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 shell: >>>> 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 command >>>> 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, problem >>>> 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=100 >>>> print "hello" >>>> 2 >>>> print "bye" >>>> #+END_SRC >>>> >>>> #+RESULTS: >>>> #+begin_example >>>> >>>> x=100 >>>>>>> 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=100 >>>> print "hello" >>>> 2 >>>> print "bye" >>>> #+END_SRC >>>> >>>> #+RESULTS: >>>> : x=100 >>>> : 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 would 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? > Hi Eric, was asked off-list not to send patches... Sorry, Andreas