On Fri, Nov 15, 2013 at 1:29 PM, JL <[email protected]> wrote:
> One of my favorite tools in C/C++ language is the preprocessor macros.
>
> One example is switching certain print messages for debugging use only
>
> #ifdef DEBUG_ENABLE
> DEBUG_PRINT print
> #else
> DEBUG_PRINT
>
> Is it possible to implement something similar in python? Thank you.
There are usually other ways to do things. For instance, you can
define a function to either do something or do nothing:
if debug_mode:
debug_print = print
else:
debug_print = lambda: None
debug_print("This won't be shown unless we're in debug mode!")
But as Dave says, you could write a preprocessor if you need one.
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list