emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Richard Stanton <stanton@haas.berkeley.edu>
To: John Kitchin <jkitchin@andrew.cmu.edu>
Cc: Kyle Meyer <kyle@kyleam.com>, emacs-orgmode@gnu.org
Subject: Re: Extraneous output from Python code blocks using :session option
Date: Thu, 12 Mar 2015 08:34:01 -0700	[thread overview]
Message-ID: <210D96E7-43E3-4438-8401-7841C6612023@haas.berkeley.edu> (raw)
In-Reply-To: <m2lhj22qk0.fsf@andrew.cmu.edu>

This looks great. While we're patching this code, why does having blank lines inside function definitions cause such problems in :session mode? It would be nice if you could just type any valid Python code and have it execute (like you can in an IPython notebook cell)


> On Mar 12, 2015, at 8:17 AM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> 
> Nice. I hope this makes it into org-mode one day.
> 
> In the mean time, I crafted an approach with another hook function that
> is described here:
> 
> http://kitchingroup.cheme.cmu.edu/blog/2015/03/12/Making-org-mode-Python-sessions-look-better/
> 
> This can be done in an init file.
> 
> Kyle Meyer writes:
> 
>> Richard Stanton <stanton@haas.berkeley.edu> wrote:
>>> I'm trying to use the :session option so I can import modules, etc.,
>>> just once at the beginning of my document, like with am IPython
>>> notebook. Unfortunately, the output from these code blocks contains
>>> some extraneous characters. For example:
>>> 
>>> #+BEGIN_SRC python :session :results output
>>> a = 2
>>> b = 3
>>> c = 4
>>> print 'a=      ', a
>>> print 'b =     ', b
>>> print 'a + b = ', a+b
>>> #+END_SRC
>>> 
>>> #+RESULTS:
>>> :
>>> : >>> >>> a=       2
>>> : b =      3
>>> : a + b =  5
>> 
>> I also see this behavior.  I asked the list some time ago [1], but I
>> didn't follow up beyond the initial email.
>> 
>>> How can I stop the production of all those ">" signs (sometimes
>>> they're dots), which don't appear if I run the same code block without
>>> the :session option?
>> 
>> I've attached a patch that seems to fix the example you gave and the
>> cases from my earlier email.  I don't know enough about babel's
>> internals to know if it is a good way to fix it, but at least it might
>> serve as a quick fix for you until there is a better solution.
>> 
>> [1] http://thread.gmane.org/gmane.emacs.orgmode/79014
> 
> --
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu

  reply	other threads:[~2015-03-12 15:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-11  3:38 Extraneous output from Python code blocks using :session option Richard Stanton
2015-03-11 18:29 ` Kyle Meyer
2015-03-11 18:54   ` Richard Stanton
2015-03-12 15:17   ` John Kitchin
2015-03-12 15:34     ` Richard Stanton [this message]
2015-03-12 21:23       ` Kyle Meyer
2015-03-13  6:58         ` Kyle Meyer
2015-03-13  8:21           ` Nicolas Goaziou
2015-03-13 14:40             ` Kyle Meyer
2015-03-14  8:26               ` Nicolas Goaziou
2015-03-16  0:40                 ` Kyle Meyer
2015-03-12 21:21     ` Kyle Meyer

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=210D96E7-43E3-4438-8401-7841C6612023@haas.berkeley.edu \
    --to=stanton@haas.berkeley.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=jkitchin@andrew.cmu.edu \
    --cc=kyle@kyleam.com \
    /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).