"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm trying to use the gpp utility (Gnu points to > http://en.nothingisreal.com/wiki/GPP) to do conditional compilation in > Python, and I'm running into a problem: the same '#' character > introduces Python comments and is used by default to introduce #ifdef > etc. lines. > > Here's an example of what I'm trying to do: > > #ifdef DEBUG > stderr.write("variable is...") #details of msg omitted > #endif >
Why do you want conditional compilation. Is there anything wrong with: if __debug__: stderr.write("variable is...") #details of msg omitted If you run Python with the -O command line option the code protected by the if statement will be optimised out. For most other purposes where you might use conditional compilation just adding 'if' statements to execute at runtime (or try/except) will do the same purpose: if sys.platform=='win32': def foo(): ... something ... else: def foo(): .... something different ... -- http://mail.python.org/mailman/listinfo/python-list