From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jack Kamm Subject: Re: ob-python.el: questions about output Date: Mon, 24 Feb 2020 08:17:08 -0800 Message-ID: <878sksx8mz.fsf@gmail.com> References: <87eeuky4cn.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:39345) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6GR3-0002ue-R5 for emacs-orgmode@gnu.org; Mon, 24 Feb 2020 11:18:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6GR2-0002VO-P6 for emacs-orgmode@gnu.org; Mon, 24 Feb 2020 11:18:21 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:42122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6GR2-0002Ux-K0 for emacs-orgmode@gnu.org; Mon, 24 Feb 2020 11:18:20 -0500 Received: by mail-pf1-x42a.google.com with SMTP id 4so5594373pfz.9 for ; Mon, 24 Feb 2020 08:18:20 -0800 (PST) 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-mx.org@gnu.org Sender: "Emacs-orgmode" To: R C Cc: emacs-orgmode@gnu.org Hi RC, R C writes: > My python src blocks often have both graphical output as well as the > results of some numerical calculation displayed using print statements. > > When exported I would like the line: return 'img/ex1.png' not to be > included in the listing of the src block. > > Also, the output of the print statement is not displayed in this case. The external ob-jupyter [0] accomplishes what you want: 1. It can return multiple types of output, e.g. print statements and plots. 2. It doesn't require the "return" statement. It's main limitations are: 1. It requires jupyter. 2. It requires using session blocks. I'd recommend checking it out. It has excellent Python support. If you prefer a native solution, I think the options are: 1. noweb (as Eric mentioned). Then you only need to write the code once, but note that it will be executed twice. 2. Using multiple session blocks to return output and value separately. Since they use the same state, you would only need to execute the code once. 3. Possibly, you could insert the link to the image separately, create a named reference to it, and pass it to the Python block via ":var", which would create at an image at that link. Then use ":results output" to capture the print statements. I'm not 100% sure if this will work. [0] https://github.com/dzop/emacs-jupyter