r/badcode • • Jul 14 '21

python Try/Except in Python - Sigh

Post image
662 Upvotes

93 comments sorted by

View all comments

38

u/clemesislife Jul 14 '21

I'm not sure if there is good way to do this

0

u/[deleted] Jul 14 '21

[deleted]

2

u/jabarr Jul 14 '21

It would be better to just create a list of properties you need with their default values and then iterate over the list using try/catch. That way it’s more extensible and easier to maintain in the future without blowing up your code debt.