Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

- @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...

At least the article doesn't advocate inserting them into __builtins__ (which I have seen people do with their own special custom functions before).



> 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.


> 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: