jupyter icon indicating copy to clipboard operation
jupyter copied to clipboard

Multiple results mode?

Open indigoviolet opened this issue 3 years ago • 3 comments

Thanks for your work on this package.

Is it possible to capture results from each statement/line in the source block? For instance, the below returns : world currently, but can it be made to return

: hello
: world

?

:PROPERTIES:
:header-args: :session test :kernel python :results raw drawer replace
:END:

#+begin_src jupyter-python
"hello"
"world"
#+end_src

#+RESULTS:
: world

The IPython equivalent is

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"

indigoviolet avatar Feb 19 '22 00:02 indigoviolet

If you don't mind calling display on each line you want shown, you get the desired result.

#+begin_src jupyter-python
display("hello")
display("world")
#+end_src

#+RESULTS:
:RESULTS:
: hello
: world
:END:

nchisholm avatar Mar 20 '22 21:03 nchisholm

Thanks!

I think this (multiple results without display()) would be a useful feature to have; in my experience I use that IPython snippet in every notebook, and it is nice not to have to remember to wrap everything in display().

indigoviolet avatar Mar 21 '22 01:03 indigoviolet

Oh, I see - sorry if I stated the obvious then. It took me some time to figure out that you could call display a bunch of times to get multiple outputs. In the Jupyter notebook it is ergonomic to have each statement on a separate cell, but not as much form within org mode due to the boilerplate. Could be nice to have something like :results verbose to get an output for each line.

nchisholm avatar Mar 22 '22 21:03 nchisholm