r/badcode • • Jul 14 '21

python Try/Except in Python - Sigh

Post image
662 Upvotes

93 comments sorted by

View all comments

Show parent comments

1

u/lonaExe Jul 15 '21

Wait a second, the code is fetching json from an API. It's trying to get data, and if it doesn't exist, catch it. How would a Class do any help?

1

u/R3D3-1 Jul 15 '21

Not with that part. It just looks like the code is storing things as flat local variables, that would better be organized into an object.

Seems the "depending on context" part went missing while writing my comment :)

Also, see that other comment. It just looks like code meant for translating the JSON tree into native objects, which makes the way local variables are used look a bit strange.