Yield inside try...finally

Jeremy Fincher tweedgeezer at hotmail.com
Thu Jun 5 05:15:50 EDT 2003


Alan Kennedy <alanmk at hotmail.com> wrote in message news:<3EDDC045.E45DA524 at hotmail.com>...
> The real problem here is the fact that try..finally has been actively
> disabled inside generators, because Guido's language designers intuition
> tells him that the "contract" of finally clauses might be broken by their
> use inside a generator which might never resume. 

I wonder if he's considered relaxing that restriction to allow at most
*one* try: finally: block, or any number of try: finally: blocks whose
finally: clauses are identical (which is effectively equivalent to a
single finally: clause).  He could then just compile the finally code
into an __del__ method on the generator-iterator.

Jeremy




More information about the Python-list mailing list