Is there a way to mimic the behaviour of C/C++'s preprocessor for macros? The problem: a lot of code like this:
def foo(): # .... do some stuff if debug: emit_dbg_obj(DbgObjFoo(a,b,c)) # .... do more stuff if debug: emit_dbg_obj(DbgObjBar(d,e)) # ... and so on ... Notes: * the two-lines of debug conditional tend to really break up the flow of the surrounding code * in C you could wrap them with a macro so you could do DEBUG_EMIT(DbgObjFoo(a,b,c)), etc, with the macro only instantiating the object and processing it if the debug flag was set. The one-liner is MUCH less disruptive visually when reading code * using def debug_emit(obj): if debug: emit_dbg_obj(obj) is a poor solution, because it *always* instantiates DbgObj*, even when not needed; I want to avoid such unnecessary waste -- http://mail.python.org/mailman/listinfo/python-list