Hi,
in Jupyter one can use the python %%capture magic to redirect stdout, stderr into a variable. How do you do that in Julia with Juypter? I, most of the times, only have a pure Julia kernel running.
Maybe as a bonus: Is there a way to “tie” the output to a specific cell as well? I want to run asynchronous tasks and if I switch cells, they start to write into the standard output of other cells, which is somehow annoying
I do not know how they work together with jupyter. I do not want to redirect ALL output, just the output of some code running in specific cells in a jupyter notebook.
Does anyone know, how that would be done?
let old_stdout = stdout
rd, = redirect_stdout()
try
println("This output is redirected.\n")
finally
redirect_stdout(old_stdout) # restore original stdout
end
output = String(readavailable(rd))
println("captured the output: ", output)
end