Conditional compilation

James J. Besemer jb at cascade-sys.com
Fri May 10 08:27:04 EDT 2002


jb wrote:

> This question was probably asked many times.
>
> It does not seem to be possible to "comment out" blocks of code, which would
> be a very nice feature for testing purposes. (Maybe I can do it with """
> but that looks a bit cumbersome.)
>
> Any ideas, hint, proposals?

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.

Regards

--jb

--
James J. Besemer  503-280-0838 voice
http://cascade-sys.com  503-280-0375 fax
mailto:jb at cascade-sys.com







More information about the Python-list mailing list