try...finally is more powerful than I thought.
peter at engcorp.com
Fri Nov 7 05:29:45 CET 2003
Lee Harr wrote:
> >>> def res():
> ... print 1
> ... try:
> ... print 2
> ... return 3
> ... print 4
> ... finally:
> ... print 5
> >>> res()
Why? It just proves that "finally" works, and
executes when the return statement is encountered.
(The point of my examples was to show that finally can
actually override the value that would otherwise have been
returned. I thought that was interesting, but unfortunately
I'm not sure what your example adds to the previous two posts.
Maybe I'm just missing the point...)
More information about the Python-list