Implementing #define macros similar to C on python
Roy Smith
roy at panix.com
Thu Nov 14 23:10:03 EST 2013
In article <fae7479b-ecec-4114-9750-6595fa8c78fa at googlegroups.com>,
JL <lightaiyee at gmail.com> 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.
Why would you want to? One of the most horrible things about C/C++ is
the preprocessor. Python has much better mechanisms to implement just
about anything you would do with the preprocessor.
For the example you gave, you would log things as info() or debug(), and
then adjust the filter level in the logger.
More information about the Python-list
mailing list