try/except/finally

Ethan Furman ethan at stoneleaf.us
Sat Jun 7 18:49:23 EDT 2014


On 06/06/2014 11:22 AM, Ned Batchelder wrote:
> On 6/6/14 1:47 PM, Frank B wrote:
>>
>> Ok; thanks for the underscore and clarification.  Just need to adjust my thinking a bit.
>
> Did this come up in real code?  I've seen this point about finally/return semantics a number of times, but haven't seen
> real code that needed adjusting based on it.

I don't remember if I almost had this in real code or if I learned about it first, but it can definitely be a gotcha. 
It seems to me that if the try block exits with an explicit return, and then the finally block exits with an explicit 
return, some kind of error ought to be raised.

--
~Ethan~



More information about the Python-list mailing list