About python 2.5 and its try statement.

Bruno Desthuilliers onurb at xiludom.gro
Mon Jun 26 08:50:41 EDT 2006


defcon8 wrote:
> I can't remember the proposal number,

http://docs.python.org/dev/whatsnew/pep-341.html

 but many of you reading will have
> probably read the features that will be added to python 2.5. The actual
> part I wanted to talk about was the finally part of try.

It has been here from the start (well, IIRC, it's since at least 1.5.2)
- the only limitation was that you couldn't use both 'except' and
'finally' in the same statement, so you had to wrap'em when needed.

> Isn't it
> totally defeating a compiler's job by executing the finally part even
> if there is an error in the previous statements? 

I don't see how this relates to the compiler. But anyway, the whole
point of the 'finally' clause is (and has ever been) to *ensure* this
block gets executed *whatever* happened. FWIW, the canonical use case is
resource aquisition/release.

> Or have I understood
> something wrong?

Seems so - unless it's me misunderstading your question.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list