I'm using a Python library that does something to an object do_something(my_object) and changes it. While doing so, it prints some statistics to stdout, and I'd like to get a grip on this information. The proper solution would be to change do_something() to return the relevant information, out = do_something(my_object) but it will be a while before the devs of do_something() get to this issue. As a workaround, I thought about parsing whatever do_something() writes to stdout. How can I capture stdout output between two points in the code, e.g., start_capturing() do_something(my_object) out = end_capturing() ? Continue reading...