emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Shiyuan <gshy2014@gmail.com>
Cc: emacs-orgmode@gnu.org, "Doyley, Marvin" <mdoyley@ur.rochester.edu>
Subject: Re: babel python example not reproducible
Date: Wed, 18 Jun 2014 09:59:44 -0400	[thread overview]
Message-ID: <87egym2cnn.fsf@gmail.com> (raw)
In-Reply-To: CAOm4EMuxYgB_hHTmZrA-0EKQXUT=ywR-2-=A=iZDF3t6Uz1HHQ@mail.gmail.com

Shiyuan <gshy2014@gmail.com> 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 <mdoyley@ur.rochester.edu>
> 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)

  parent reply	other threads:[~2014-06-18 20:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11  5:11 babel python example not reproducible Shiyuan
2014-06-11  7:48 ` Doyley, Marvin
2014-06-16  5:59   ` Shiyuan
2014-06-16 12:19     ` Nick Dokos
2014-06-16 14:35     ` Doyley, Marvin
2014-06-16 15:03       ` Eric Schulte
2014-06-16 16:12         ` Doyley, Marvin
2014-06-17  6:21           ` Shiyuan
2014-06-17 11:54             ` Andreas Röhler
2014-06-18 14:02               ` Eric Schulte
2014-06-18 13:59             ` Eric Schulte [this message]
2014-06-19  5:57               ` Andreas Röhler
2014-06-19 13:40                 ` Eric Schulte
2014-06-20  5:53                   ` Andreas Röhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87egym2cnn.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=gshy2014@gmail.com \
    --cc=mdoyley@ur.rochester.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).