Delaney, Timothy C (Timothy) wrote:
> Nick Coghlan wrote:
> I think if we are going to emphasise the difference, a decorator does
> not go far enough. To use a decorator, this *must* be valid syntax::
> 
>     def gen():
>         try:
>             yield
>         finally:
>             print 'Done!'
> 
> However, that generator cannot be properly used in a for-loop. So it's
> only realistically valid with the decorator, and used in a block
> statement (resource suite ;)
> 
> My feeling is that the above should be a SyntaxError, as it currently
> is, and that a new keyword is needed which explicitly allows the above,
> and creates an object conforming to the resource protocal (as I called
> it).

I think adding __exit__ and __del__ methods to generators will suffice - for a 
normal generator, it *will* get cleaned up eventually.

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to