3 ms·
By the way, try also has an else clause that behaves like the one in if https://docs.python.org/3/reference/compound_stmts.html https://docs.python.org/3/refere
by pmontra 8y ago
By the way, try also has an else clause that behaves like the one in if https://docs.python.org/3/reference/compound_stmts.html https://docs.python.org/3/reference/compound_stmts.html
- dragonwriter 8y agoIt behaves more like the main branch of “if” unless you construe “try” as “try to produce an exception”; outside of “if”, Python’s “else” pretty consistently implies exactly the wrong picture of normal flow.
- nerdwaller 8y agoI guess I wasn’t clear, because my point is generally that moving the logic to an else block in any supported control structures (if, for, try, ...) doesn’t necessarily make it clearer or cleaner.