Class cap_cout

class o2sclpy.cap_cout

Capture std::cout into a python string in order to output it to a jupyter notebook. One should use open() to begin reading std::cout and then close() to stop reading and output the contents using the Python print() functions.

Based on

https://stackoverflow.com/questions/24277488/in-python-how-to- capture-the-stdout-from-a-c-shared-library-to-a-variable

and see also

https://dzone.com/articles/redirecting-all-kinds-stdout

captured_stdout = ''
close()

Close the pipe and restore the original stdout

drain_pipe()

Collect the pipe output to captured_stdout

open()

Duplicate stdout and create a new pipe

stdout_fileno = 1
stdout_pipe = 0
stdout_save = 0
thr = 0