4 ms·
I know I'm taking a joke comment WAY too seriously, but... that "else" branch is unreachable, right?
by 3PS 3y ago
I know I'm taking a joke comment WAY too seriously, but... that "else" branch is unreachable, right?
- warble 3y agoDepends on the exception. Maybe the sun wasn't moral.
- froh 3y agothat's right, and absolutely make sense, as the church meanwhile realized unbaptized babies don't go to limbo but to heaven.
- Shish2k 3y agoCorrect (in a `try ... else` the else branch is executed when the try block reaches the end of the block with no exception, and the return is leaving the block without reaching the end) (Bonus context for anyone surprised that it is valid code — Python actually allows you to use “else” in more places than you’d expect - `for ... else` is my favourite (do a for loop over a list of things, `break` if you find the thing that you’re looking for, and then the `else` branch will be taken if you don’t find what you’re looking for. Much cleaner than keeping track of a separate i_found_the_thing bool IMO))