I am essentially trying to write a console interface with input and output for an embedded python script. Following the instructions here, I was able to capture stdout:
If you stick with the approach you outlined, inheriting your class from io.IOBase is probably a good idea.