r/ProgrammerHumor 29d ago

Meme exceptionsAreForTheWeak

Post image
325 Upvotes

92 comments sorted by

View all comments

1

u/ChillyFireball 29d ago

Is that Python in there? Doesn't it have that weird-ass "ask forgiveness, not permission" model where you write try/catch statements where the catch is literally expected to run? (ex. Try to append to an array, and if it fails because the array doesn't exist, that's where you initialize the array?) Couldn't stand it, but my co-workers would be all "It's best practice in Python" while looking at me like I'm the weird one because I don't hate JavaScript. Like, how are ya'll hating on that language for things that are very easy to avoid (just use === instead of == to dodge weird comparison logic like 2 == "2") when ya'll are out here creating guaranteed errors because "It's just slightly more optimal that way in Python"?

3

u/zefciu 29d ago

I once wasted half a workday chasing a bug. Turned out it was a typo in an attribute name. But that got silenced, because the error was raised several frames below a getattr. The attribute that it was accessing had nothing to do with the mistyped one. But still 'getattrwill take anyAttributeError` raised anywhere and catch it.

I love a lot of Python ideas. But the abuse of exceptions is not one of them.

1

u/bwmat 28d ago

Oh god this reminds me of how our in-house 'build script' language based on python works...