emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Extraneous output from Python code blocks using :session option


From: Richard Stanton
Subject: Re: [O] Extraneous output from Python code blocks using :session option
Date: Thu, 12 Mar 2015 08:34:01 -0700

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 <address@hidden> 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 <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]