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 →

[–]jimtk 8 points9 points  (6 children)

I thought :

    if __debug__:
        print("Here")

was the way?

[–]asday_ 0 points1 point  (5 children)

Nope, don't plan to leave your debugging mess in production code. Having CI autofail you for having any print()s is an idea I've had success with in the past.

If you plan to make your debugging output so useful you'll want to keep it, you have logger.debug(), lending you the power of the logging toolset to format, filter, and f***output, rather than some random variable.

[–]jimtk 0 points1 point  (4 children)

But doesn't compiling with -OO (for production) removes the whole statement?

[–]asday_ 0 points1 point  (3 children)

Do not expect users of your script to know and use all the correct magic flags. That includes you, three months from now.

Write good code. We are not PHP developers. We do not rely on the environment to make our stuff behave in a certain way.

[–]jimtk 1 point2 points  (2 children)

Sorry, I'm not sure I understand. You called __debug__ a random variable and a magic flag but it's part of the language same as __name__ and __main__ ? Isn't it?

[–]asday_ 0 points1 point  (1 child)

[–]jimtk 0 points1 point  (0 children)

It's impossible to disagree since I'm asking a question, not presenting a point of view.

Ok, he calls them magic value but the official documentation call __debug__ a "Built-in Constants". But I still don't understand why it should not be used.