triqs.utility.capture_stdout

Context manager that captures sys.stdout into a list of lines.

Defines capture_stdout, a list subclass usable in a with block. Inside the block sys.stdout is redirected to an in-memory io.StringIO buffer; on exit the buffered text is split on newlines and appended to self.

Only Python-level prints are captured. C++ output written to file descriptor 1 is not captured here – use triqs.utility.redirect for that.