Conditional compilation
Fernando Pérez
fperez528 at yahoo.com
Fri May 10 12:13:29 EDT 2002
James J. Besemer wrote:
> Prefix your code segment with
>
> if 0:
>
> and indent it a level.
>
> This is not as fully general as #ifdef but since even declarations are
> executed at runtime, it'll serve as a way to selectively include or exclude
> blocks of code.
>
Why not just use #ifdef? ;) I'm only half joking: it would take a few minutes
to whip up a shell script to run your python code through the gcc
preprocessor first before passing it to python. As long as you have spaces in
your normal comments (no #include as a comment), you should be allright, no?
I haven't actually tried it, so maybe the preprocessor would somehow get
confused, and yes, it's a bit of a twisted idea. But fun ;)
cheers,
f.
More information about the Python-list
mailing list