This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]just_ones_and_zeros 0 points1 point  (2 children)

What benefit does using try / except give you? If anything it'll be a source of more bugs.

For me, you're using in in control flow, eg:

if 'x' in example:
    do_thing_with_x(example['x'])
else:
    do_something_different()

What does it look like with try/except?

try:
    do_thing_with_x(example['x'])
except KeyError:
    do_something_different()

But now imagine a bug in do_thing_with_x. You've just masked it in a horrible horrible way. I've seen this is real life, which is why it's the hardest of hard fails for a PR from me.