News for hackers. Stuff that matters.
Re:Pope tempted by Python. Signs off on coding scheme for kids by Shish2k on Saturday October 28, 2023 @07:26PM (#38054448)
Correct (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))

There are no comments on this comment yet.