A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-May/053367.html below:

[Python-Dev] PEP 340 -- concept clarification

[Python-Dev] PEP 340 -- concept clarificationDelaney, Timothy C (Timothy) tdelaney at avaya.com
Thu May 5 01:28:01 CEST 2005
Nick Coghlan wrote:

> Ah, someone else did post this idea first :)

I knew I was standing on the shoulders of others :)

> To deal with the generator issue, one option would be to follow up on
> Phillip's idea of a decorator to convert a generator (or perhaps any
> standard iterator) into a block iterator.
> 
> I think this would also do wonders for emphasising the difference
> between for loops and block statements.

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).

Tim Delaney
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4