return self

def write(self, string):
    self._stomach.write(string)

def flush(self):
    pass

def autopsy(self):
    return self._stomach.getvalue()

def __exit__(self, *args):
    for ch in self._orig:
        setattr(sys, ch, self._orig[ch])
Suppress stdout / stderr print from Python functions