3 basic keywords
try:
except: just to except and skip the remaining code, can specify error type
finally: run anyway
Traceback message
for i in range(10):
print(i)
if i == 5:
raise Exception('this is my test msg')program will end after raising exception
assertion error
it’s a sanity check not to expect
logging
import logging
logging.basicConfig(filename=’myProgramLog.txt’, level=logging.DEBUG, format=’%(asctime)s - %(levelname)s - %(message)s’)
#logging.disable(logging.CRITICAL)
logging.debug('start of debug')