Python for Biologists
Lectures
Labs
Resources
Assessment
Schedule
About
GitHub →
← Lab 4
Errors —
staying in control
Catch it & carry on
▸
Read a traceback — the last line names the error
▸
try: … except KeyError: … carry on
▸
Catch the specific type, not a bare except:
Raise & survive
▸
raise ValueError("that isn't DNA") on bad input
▸
Your own error types: class NotDNAError(ValueError)
▸
A batch job that records failures and keeps going
📓 03 · Errors — basics →
📓 04 · Errors — advanced →
← Previous
←
Next →
→
Python for Biologists