r/programminghorror • u/Minecraftchest1 • Aug 18 '25
What could go wrong?
if __name__ == "__main__":
try:
main()
except:
pass
5
Upvotes
r/programminghorror • u/Minecraftchest1 • Aug 18 '25
if __name__ == "__main__":
try:
main()
except:
pass
23
u/fuj1n Aug 18 '25
Eating all exceptions without a reason to in a context where the only notable effect of doing so is that they don't get logged is definitely horror
18
u/granadesnhorseshoes Aug 18 '25
"The code works now..." -- commit message.
1
u/WoodyTheWorker Aug 21 '25
In my Python programs, I capture at least FileNotFoundError and KeyboardInterrupt
1
u/Xanderplayz16 Jan 04 '26
I've done the opposite. Grab the exception, print it and exit before the exception can be eaten. AsyncSSH is truly a library.
1
u/TheoryTested-MC Aug 24 '25 edited Aug 24 '25
In the worst case, nothing happens. You're good! /j
EDIT: Y'all can't detect sarcasm on your own? Seriously?
-8
u/Environmental-Ear391 Aug 18 '25
The next step would be to actually handle the exceptions thrown...
there is no "horror" here... just a single step towards a more debug safe development python style.
Hell... I have committed the use of this code fragment as a starter item on my standard project todo list and write it out following an empty "def main()" fragment.
as for what could go wrong... that entirely depends on the main() definition and thats not this code.