Comment

Comment by gnahckire

> that code in Python can fail at a huge number of points even in a small function

This is why unit-tests are really important in Python.

> We should have language-level mechanisms for being explicit about what's supposed to happen when unexpected situations happen.

That's implemented as a try-except block. You're not supposed to catch errors at the low level unless you're explicitly handling them. If there's an error, bubble it up to the main().

Python's try-except can catch classes, sub-classes, and/or groups (tuples) of classes. It's important to categorize your errors.

parent gnahckire 7 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton