You are here: Home / Community / Workshops / 2008 - Fribourg / Content / Shakespeare / Effect / bin / python / assert.py

assert.py

####
#       The usual debugging style assertion routines
####

#  not used
#  last updated 29-Jul-2008

Assertion = "Assertion Failed"
Die = "Die"

# this definition throws a "SyntaxError: invalid syntax"
# it seems assert is a reserved word.  can it be overloaded?
def assert(*args):
        from utils import seq_to_str
        if not args[0]:
                if len(args) == 1:
                        raise Assertion, args[1]+"()"
                else:
                        raise Assertion, args[1]+"(): " + seq_to_str(args[2:])

def die(*args):
        from utils import seq_to_str
        if len(args) == 1:
                raise Die, args[0]+"()"
        else:
                m = seq_to_str(args[1:])
                raise Die, args[0]+"(): " + m
by AMcneil last modified Feb 29, 2016 12:25 PM