From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Stanton Subject: Re: Extraneous output from Python code blocks using :session option Date: Thu, 12 Mar 2015 08:34:01 -0700 Message-ID: <210D96E7-43E3-4438-8401-7841C6612023@haas.berkeley.edu> References: <1931A590-8B23-4412-86C7-F3571EC466FF@haas.berkeley.edu> <87r3sv2xra.fsf@kyleam.com> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW57j-0008Fc-5S for emacs-orgmode@gnu.org; Thu, 12 Mar 2015 11:34:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YW57f-0003SA-2b for emacs-orgmode@gnu.org; Thu, 12 Mar 2015 11:34:11 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:35330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW57e-0003S4-UV for emacs-orgmode@gnu.org; Thu, 12 Mar 2015 11:34:07 -0400 Received: by pdbfp1 with SMTP id fp1so21004798pdb.2 for ; Thu, 12 Mar 2015 08:34:05 -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: John Kitchin Cc: Kyle Meyer , emacs-orgmode@gnu.org 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 = wrote: >=20 > Nice. I hope this makes it into org-mode one day. >=20 > In the mean time, I crafted an approach with another hook function = that > is described here: >=20 > = http://kitchingroup.cheme.cmu.edu/blog/2015/03/12/Making-org-mode-Python-s= essions-look-better/ >=20 > This can be done in an init file. >=20 > Kyle Meyer writes: >=20 >> 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: >>>=20 >>> #+BEGIN_SRC python :session :results output >>> a =3D 2 >>> b =3D 3 >>> c =3D 4 >>> print 'a=3D ', a >>> print 'b =3D ', b >>> print 'a + b =3D ', a+b >>> #+END_SRC >>>=20 >>> #+RESULTS: >>> : >>> : >>> >>> a=3D 2 >>> : b =3D 3 >>> : a + b =3D 5 >>=20 >> I also see this behavior. I asked the list some time ago [1], but I >> didn't follow up beyond the initial email. >>=20 >>> 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? >>=20 >> 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. >>=20 >> [1] http://thread.gmane.org/gmane.emacs.orgmode/79014 >=20 > -- > 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