Implementing #define macros similar to C on python
Irmen de Jong
irmen.NOSPAM at xs4all.nl
Fri Nov 15 18:20:49 EST 2013
On 15-11-2013 3:29, JL 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.
>
You could just run cpp (or gcc -E) on your python-with-macros-file to generate the final
.py file. But: yuck, eww, gross.
Irmen
More information about the Python-list
mailing list