r/AskProgramming • u/Excellent-Fan8457 • Jul 11 '26
When to use try/except vs if/else
I was making a simple program when I wondered when to use try and except this is the code I'm looking at.
if (Path.home() / "Desktop").exists():
desktop_path = Path.home() / "Desktop"
else:
desktop_path = Path.home() / "OneDrive/Desktop"
3
Upvotes
View all comments
Show parent comment
3
u/TimonAndPumbaAreDead Jul 11 '26
This is a really important concept to grok for any sort of distributed or threaded system