Skip to content

Append/prepend results #221

Open
Open
@jamieforth

Description

@jamieforth
#+begin_src jupyter-python
  n = 0
  n
#+end_src

#+results:
: 0

Prepending a single result is fine.

#+begin_src jupyter-python :results prepend
  n = n + 1
  n
#+end_src

#+results:
: 4
: 3
: 2
: 1

Appending with a single resuilt is fine.

#+begin_src jupyter-python :results append
  n = n + 1
  n
#+end_src

#+results:
: 5
: 6
: 7
: 8

Prepending multiple results is fine.

#+begin_src jupyter-python :results prepend
  n = n + 1
  print("n is {}".format(n))
  n
#+end_src

#+results:
:RESULTS:
: n is 12
: 12
:END:
:RESULTS:
: n is 11
: 11
:END:
:RESULTS:
: n is 10
: 10
:END:
:RESULTS:
: n is 9
: 9
:END:

Appending multiple results prepends after the first result.

#+begin_src jupyter-python :results append
  n = n + 1
  print("n is {}".format(n))
  n
#+end_src

#+results:
:RESULTS:
: n is 13
: 13
:END:
:RESULTS:
: n is 16
: 16
:END:
:RESULTS:
: n is 15
: 15
:END:
:RESULTS:
: n is 14
: 14
:END:

Async breaks append/prepend all together.

#+begin_src jupyter-python :results prepend :async yes
  n = n + 1
  n
#+end_src

#+results:
:RESULTS:
: 17
: 18
: 19
: 20
:END:
#+begin_src jupyter-python :results append :async yes
  n = n + 1
  n
#+end_src

#+results:
:RESULTS:
: 21
: 22
: 23
: 24
:END:
#+begin_src jupyter-python :results prepend :async yes
  n = n + 1
  print("n is {}".format(n))
  n
#+end_src

#+results:
:RESULTS:
: n is 25
: 25n is 26
: 26n is 27
: 27n is 28
: 28
:END:
#+begin_src jupyter-python :results append :async yes
  n = n + 1
  print("n is {}".format(n))
  n
#+end_src

#+results:
:RESULTS:
: n is 29
: 29n is 30
: 30n is 31
: 31n is 32
: 32
:END:

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions