Rudinberry
Rudinberry

Reputation: 165

How to print ALL output of a cell in Julia Jupyter notebook?

I am running Julia through (Anaconda) Jupyter notebook. When I run a cell like this

5 + 6
3 + 17

The output is

[out:] 20

How can I print out the output of all lines, i.e.,

[out:] 11

[out:] 20

Upvotes: 2

Views: 821

Answers (2)

xgdgsc
xgdgsc

Reputation: 1367

If you don' t use jupyter notebook' s markdown capabilities you can try my workflow using my branch of julia vscode extension described at Release persist inline results · xgdgsc/julia-vscode. Which shows and persists inline results of every cell line.

This is an alternative workflow for whom suffering from unusable slow long jupyter notebook experience. I prefer this more condensed view of code and results.

Upvotes: 0

phipsgabler
phipsgabler

Reputation: 20960

But there is only one output of the cell! Expressions have no "output", they have a value. The cell behaves like a block:

output = begin
    5 + 6
    3 + 17
end
show(output)

The expressions in the begin block are sequenced (i.e., evaluated in order, so that their side effects are run), and the end result is then the result of the block. This end result is printed.

If you want to see the intermediate results of the individual expressions, you have to either split the block, or use side effects:

println(5 + 6)
3 + 17

Upvotes: 0

Related Questions