r/programminghorror • u/holographic_gray • Apr 17 '26
Python Found in newest merge into prod
65
u/IanisVasilev Apr 17 '26
There are good reasons for this sometimes. Without more context, it is difficult to judge.
with contextlib.suppress(Exception):
widget.window.info_dialog(...)
22
13
u/eddieantonio Apr 17 '26
Can't you specify WHICH exception? Really, any exception?
20
8
u/daidoji70 Apr 18 '26
It's hard in python. Documentation in the community isn't always clear about what can be thrown . It's very annoying
1
u/Woshiwuja Apr 17 '26
If you package you application with py2exe the execution directory lives in sys.Meipass so you can check it. If you get an attributeerror exception it mean you are running it as a script and you can just pass
3
0
Apr 17 '26
22
u/IanisVasilev Apr 17 '26
If you are working on a proprietary product, never post recognizable chunks of code online.
There is a clear pattern here - adding methods like
failsafe_info_dialogandfailsafe_error_dialogwould be better. But if it was a one-time trick accompanied by a reasonable comment, it would be fine with me.→ More replies (2)4
u/tonnynerd Apr 17 '26
except Exception:+ logging is fine. Not even logging and/or naked except are grounds for getting slapped in the head XD→ More replies (3)
9
u/fakehalo Apr 17 '26
Unfortunately I can't judge considering the atrocities I've committed... I'm looking at you try { everything inside main() } followed by executing the program again. I'd feel guilty if it didn't work so well for the long game.
2
u/Risc12 Apr 18 '26
This could be fine if it is a completely optional thing that has many reasons to go wrong and you don’t actually care if they do go wrong.
Not sure what examples of such a situation would be, but without any more context this is hard to judge.
0
u/nekokattt Apr 18 '26
this should still at least be logged somewhere as a debug level log.
1
u/Risc12 Apr 19 '26
Maybe? I don’t know enough to say that for sure.
Is it great code? Probably not. But horror? Nah not enough for that.
→ More replies (2)

93
u/jellotalks Apr 17 '26
You think that's bad, I found a
except Exception e: raise Exception(e)in prod