def dbcheck(exprstr, globals=None, locals=None):
 def decorate(func):
  expr = compile(exprstr, ('dbcheck-%s' % func.__name__), 'eval')
  def check(*args, **kwds):
   if (not eval(expr, globals, locals)):
    raise DbcheckError(exprstr, func, args, kwds)
   return func(*args, **kwds)
  return check
 return decorate

def dbcheck ( exprstr , globals = None , locals = None ) : def decorate ( func ) : expr = compile ( exprstr , ( 'dbcheck-%s' % func . __name__ ) , 'eval' ) def check ( * args , ** kwds ) : if ( not eval ( expr , globals , locals ) ) : raise DbcheckError ( exprstr , func , args , kwds ) return func ( * args , ** kwds ) return check return decorate
decorator to implement debugging assertions .