7

I would like IPython Notebook to display every line output without explicitly using the print command. Example:

a, b, c = 1, 2, 4

a

b

c

would only display 4 in the output cell, but I would like it to display

1

2

4

Is there a way to do this? I would also be able to selectively suppress some lines (by using ;?)

B6ka
  • 71
  • 1
  • 3
  • Not sure what you mean - works fine for me: https://dl.dropboxusercontent.com/u/6086504/ipy.png – Nir Alfasi Aug 01 '15 at 16:58
  • @alfasin, the question is reasonable. It's about ipython notebook :) – cel Aug 01 '15 at 20:41
  • @cel maybe it's not a notebook, but it *is* an online version of IPython: https://www.pythonanywhere.com/try-ipython/ – Nir Alfasi Aug 01 '15 at 20:44
  • I am using IPython Notebook for Python 2, which runs in a browser – B6ka Aug 01 '15 at 22:54
  • Does this answer your question? [How to display full output in Jupyter, not only last result?](https://stackoverflow.com/questions/36786722/how-to-display-full-output-in-jupyter-not-only-last-result) – Tomerikoo Mar 27 '22 at 17:31

2 Answers2

12

The answer is

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

Type that on a cell, run it, and from then on each command will display its own output. source

enter image description here

If you don't want to see the output of a particular command, just end it with ";" source

Rub
  • 2,071
  • 21
  • 37
0

This isn't exactly what you're looking for, but if you just want to see the output of multiple variables, you can list the expressions with comma in between: a, b, c would display 1, 2, 4

zzzzzzz
  • 175
  • 1
  • 5