From mboxrd@z Thu Jan 1 00:00:00 1970 From: R C Subject: Re: ob-python.el: questions about output Date: Wed, 26 Feb 2020 23:29:03 -0500 Message-ID: References: <87eeuky4cn.fsf@gmail.com> <878sksx8mz.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000af19d2059f8b5a52" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:49645) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7FTo-0002Vm-Ps for emacs-orgmode@gnu.org; Thu, 27 Feb 2020 04:29:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7FTn-0008Lk-FG for emacs-orgmode@gnu.org; Thu, 27 Feb 2020 04:29:16 -0500 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:43969) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7FTn-0008Kg-8q for emacs-orgmode@gnu.org; Thu, 27 Feb 2020 04:29:15 -0500 Received: by mail-qt1-x829.google.com with SMTP id g21so1746353qtq.10 for ; Thu, 27 Feb 2020 01:29:14 -0800 (PST) In-Reply-To: <878sksx8mz.fsf@gmail.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-mx.org@gnu.org Sender: "Emacs-orgmode" To: Jack Kamm Cc: emacs-orgmode@gnu.org --000000000000af19d2059f8b5a52 Content-Type: text/plain; charset="UTF-8" Hi Jack, Thanks for your suggestion to use ob-jupyter. That gives me the stdout and graphical output in separate results blocks as I wanted, and no return statement is needed. I don't know if there are any side-effects to using multiple sessions in a single org file, but so far it seems to work quite well. On Mon, Feb 24, 2020 at 11:18 AM Jack Kamm wrote: > 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 > -- Regards, RC --000000000000af19d2059f8b5a52 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Jack,
Thanks for your suggestion to use = ob-jupyter. That gives me the stdout and graphical output in separate resul= ts blocks as I wanted, and no return statement is needed. I don't know = if there are any side-effects to using multiple sessions in a single org fi= le, but so far it seems to work quite well.

On Mon, Feb 24, 2020= at 11:18 AM Jack Kamm <jackkamm@g= mail.com> wrote:
Hi RC,

R C <recifx@gmail.= com> 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


--
Regards,
RC
--000000000000af19d2059f8b5a52--