raise Exception(msg)
try: code block except Exception as err: error handling
- convert traceback stack info to be a string
- Python -O option will disable assertions
import logging logging.disable(logging.CRITICAL) logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(filename='myProgramLog.txt', level=logging.DEBUG, format='(asctime)s - %(levelname)s - %(message)s') logging.debug('Start of program')