Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • I just tried this with redirect_stdout(None) and it didn't work. The module producing the output is written in C++, maybe that has something to do with it. Commented Apr 21, 2019 at 18:33
  • how 'does it not work'? because it really should! see e.g. this question: stackoverflow.com/questions/49757674/… Commented Apr 22, 2019 at 6:50
  • Maybe it's just a corner case, I tried wrapping a call to caffe.Net() in with redirect_stderr(None) and still got a load of debug messaged dumped to stderr. Turns out you can disable those for the specific case of Caffe another way but I guess disabling standard output is not that easy for modules that use std::iostream under the hood. Commented Apr 22, 2019 at 9:21
  • what if one wants to redirect both stdout and stderr to the same place? Commented Oct 25, 2021 at 11:00
  • 1
    @baxx with redirect_stdout(sys.stderr): and then you could redirect stderr (or the other way round). Commented Oct 25, 2021 at 21:22