Tips and Traps¶
If you need trackback information when throwing an exception use
raise ExceptionClass(msg)
, otherwise, usesys.exit(msg)
instead.The
assert
statement (which raisesAssertionError
if the assertion is not met) is a very good way to ensure conditions to be met.:::python assert some_condition