Eric Matthes on Nostr: Python people, do you have a clear policy about when to use exceptions vs. if blocks? ...
Python people, do you have a clear policy about when to use exceptions vs. if blocks?
For example, say you're trying to open a file that may not exist. Do you check if the file exists before opening it, or just try to open it and then catch the exception if it doesn't exist?
Published at
2023-08-19 17:33:22Event JSON
{
"id": "4882f5a4f9b23a2da9cfd761eaa321e138271e6806a0e605e046ad50b8761e0e",
"pubkey": "4c3a0c56329e1bedf92bfe29cc30b90a6577984de156a64b480001baa9d92701",
"created_at": 1692466402,
"kind": 1,
"tags": [
[
"proxy",
"https://fosstodon.org/users/ehmatthes/statuses/110917478131917646",
"activitypub"
]
],
"content": "Python people, do you have a clear policy about when to use exceptions vs. if blocks?\n\nFor example, say you're trying to open a file that may not exist. Do you check if the file exists before opening it, or just try to open it and then catch the exception if it doesn't exist?",
"sig": "2b3b945d438325bf5f71ab6657ee1f2fd95d8963d4dd70e225975d028cf1882d88b9925e45c62a7bea6a4d3f22d150c6b3395e68d24d528a5303a6e5f8b41bb6"
}