Assertions

Tobiah toby at tobiah.org
Thu Sep 21 12:29:07 EDT 2017


Are these completely equivalent?

def foo(thing):

        assert(thing > 0), "Thing must be greater than zero"


def foo(thing):

        if not (thing > 0): raise AssertionError("Thing must be greater than zero")


Other than the fact that the assertion can be turned off
with -O?


Thanks,


Tobiah



More information about the Python-list mailing list