25 ms·
- @redirect - logging This suggestion (logging) doesn't help if it's e.g. other code you don't have control over, but this is also available as a context manag
by misnome 4y ago
- @redirect - logging
This suggestion (logging) doesn't help if it's e.g. other code you don't have control over, but this is also available as a context manager in the standard library as "redirect_stdout": https://docs.python.org/3/library/contextlib.html#contextlib.redirect_stdout https://docs.python.org/3/library/contextlib.html#contextlib...
At least the article doesn't advocate inserting them into __builtins__ (which I have seen people do with their own special custom functions before).
- gjulianm 4y ago> This suggestion (logging) doesn't help if it's e.g. other code you don't have control over, Most of the time, other code uses the logging module so you do have control over that output. I haven't seen code not controlled by me that uses print() without me wanting it to.
- dragonwriter 4y ago> Most of the time, other code uses the logging module so you do have control over that output. I haven't seen code not controlled by me that uses print() without me wanting it to. If you are a traditional software engineer, the other people's code you deal with as an upstream depency probably looks different than the other people's code data (or many other) scientists work with.