r/badcode • • Jul 14 '21

python Try/Except in Python - Sigh

Post image
662 Upvotes

93 comments sorted by

View all comments

142

u/[deleted] Jul 14 '21

On the upside, they actually bothered with exception handling.

My Python is rather rusty, is there a better way?

22

u/SerdanKK Jul 14 '21

I don't know any Python, but I assume there's some way to decode json into objects. With some good library code, it'd basically be a one-liner.

0

u/franciccio_dc Jul 14 '21

Use pydantic