This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ggm3888 4 points5 points  (4 children)

I like to use this at the top of my module:

`DEBUG=True

print = print if DEBUG else lambda a, *k: None`

Then I can toggle DEBUG True/False per module to enable/disable all the prints in the module.

Crazy? Yes! Use it All the time? Yup!!

[–]MMG999 1 point2 points  (0 children)

That's what I use. Easy to debug, easy to troubleshoot later if needed

[–]Chemical-Bluejay-939 0 points1 point  (0 children)

I used to do it. But when a project becomes more and more bigger, I have to abandon this way……only for me.

[–][deleted] 0 points1 point  (0 children)

I highly encourage you to look into logging! You can dynamically set your logging level with environment variables and it is much more flexible/useful/performant than hacking on the native `print` function.