I would have assumed a finally clause with only a pass to be pointless.
But in a Bottle template, the following code for an optional include would not work without it.
The result would contain everything before, and the included code itself, but nothing after it.
(See the corresponding question.)
try:
include(optional_view)
except NameError:
pass
finally:
pass
What does finally: pass do, and when is it useful?
finally: passdoes nothing, but you don't actually havefinally: pass. You're writing a Bottle template, not Python, and you have broken Bottle template syntax.Bottle templates ignore indentation in inline code, which means they need a different way to tell when a block statement ends. Bottle templates use a special
endkeyword for this. Your try-except needs anend:Otherwise, the
exceptblock continues, and stuff that wasn't supposed to go in theexceptis considered part of theexcept.With
finally: pass, the stuff that was incorrectly part of theexceptis now incorrectly part of thefinally, so it runs in cases where it wouldn't have run as part of theexcept.