From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Extraneous output from Python code blocks using :session option Date: Thu, 12 Mar 2015 11:17:35 -0400 Message-ID: References: <1931A590-8B23-4412-86C7-F3571EC466FF@haas.berkeley.edu> <87r3sv2xra.fsf@kyleam.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW4rq-00058Z-4E for emacs-orgmode@gnu.org; Thu, 12 Mar 2015 11:17:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YW4rj-0004v7-UG for emacs-orgmode@gnu.org; Thu, 12 Mar 2015 11:17:46 -0400 Received: from smtp.andrew.cmu.edu ([128.2.105.204]:35147) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW4rj-0004uY-Q1 for emacs-orgmode@gnu.org; Thu, 12 Mar 2015 11:17:39 -0400 In-reply-to: <87r3sv2xra.fsf@kyleam.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: Kyle Meyer Cc: Richard Stanton , emacs-orgmode@gnu.org 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 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