any macro-like construct/technique/trick?
pinard at iro.umontreal.ca
Sat Jun 4 14:08:38 CEST 2005
> Mac a écrit :
> > # .... do some stuff
> > if debug:
> > emit_dbg_obj(DbgObjFoo(a,b,c))
> Assuming your debug functions always return true, you could use:
> assert emit_dbg_obj(DbgObjFoo(a,b,c))
> and have this code executed -or not- depending on the use of "-O"
Dirty, dirty trick :-).
`assert' is quite useful in its real and genuine purpose. There is
something heretic in allowing side effects in `assert' statements. A
few centuries ago, Python programmers doing this were burnt in public,
and this is how Python got forgotten for so long. (Guido rediscovered
it a dozen years ago, the wise guy attributed all the merit to himself!)
François Pinard http://pinard.progiciels-bpi.ca
More information about the Python-list