Wrap subprocess' stdout/stderr
I'd like to both capture and display the output of a process that I invoke through Python's subprocess. I thought I could just pass my file-like object as named parameter stdout and stderr I can see that it accesses the fileno attribute - so it is doing something with the object. However, the write() method is never invoked. Is my approach completely off or am I just missing something? class Process(object): class StreamWrapper(object): def __init__(self, stream): self._stream = stream self._buffer = [] def _print(self, msg): print repr(self), msg def __getattr__(self, name): if not name in [