What are the implications of using assert vs. raise Exception

python

Solution

Assertions can be disabled with the `-O` flag when starting Python. For this reason, use assertions only for sanity-checking, not for checking that is part of your program logic.

Besides this, there is of course the difference that assertions raise `AssertionError`, which you really shouldn't catch. When you raise an exception, you can make the type of the exception appropriate to the error and catch it later.

Problem

Are there any significant differences with the following? ``` raise Exception("some exception") assert False, "some exception" ```

Original source

Related problems