Please see the following question I asked on stackoverflow: https://stackoverflow.com/questions/69203700/how-to-capture-the-stdout-of-the-python-interpreter-inside-the-rust-program-when
How can I achieve this with pyo3?
The use case is to envelope the output with the logger used by the Rust application.