7. Error handling Flashcards

1
Q

3 basic keywords

A

try:

except: just to except and skip the remaining code, can specify error type
finally: run anyway

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Traceback message

A

for i in range(10):
print(i)

    if i == 5:
        raise Exception('this is my test msg')

program will end after raising exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

assertion error

A

it’s a sanity check not to expect

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

logging

A

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')
How well did you know this?
1
Not at all
2
3
4
5
Perfectly