I have a huge python code with lots of print statements useful for debugging. I want to be able to enable or disable them in one go, without poring over the hundreds of printf
's and commenting them each time.
In C, a #define
can be used to comment out unneeded parts of the code using #ifdef
like this-
#define debug
#ifdef debug
printf("Debug on")
#endif
If I don't want to be in debug mode, I can simply comment #define debug and none of my print
statements will compile.
How can this functionality be done in Python?