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-April/053101.html below:

[Python-Dev] Re: anonymous blocks

[Python-Dev] Re: anonymous blocksSteven Bethard steven.bethard at gmail.com
Thu Apr 28 18:21:59 CEST 2005
On 4/28/05, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Neil Schemenauer wrote:
> 
> > The translation of a block-statement could become:
> >
> >         itr = EXPR1
> >         arg = None
> >         while True:
> >             try:
> >                 VAR1 = next(itr, arg)
> >             except StopIteration:
> >                 break
> >             try:
> >                 arg = None
> >                 BLOCK1
> >             except Exception, exc:
> >                 err = getattr(itr, '__error__', None)
> >                 if err is None:
> >                     raise exc
> >                 err(exc)
> 
> That can't be right. When __error__ is called, if the iterator
> catches the exception and goes on to do another yield, the
> yielded value needs to be assigned to VAR1 and the block
> executed again. It looks like your version will ignore the
> value from the second yield and only execute the block again
> on the third yield.

Could you do something like:
    itr = EXPR1
    arg = None
    next_func = next
    while True:
        try:
            VAR1 = next_func(itr, arg)
        except StopIteration:
            break
        try:
            arg = None
            next_func = next
            BLOCK1
        except Exception, arg:
            try:
                next_func = type(itr).__error__
            except AttributeError:
                raise arg


?

STeVe

-- 
You can wordify anything if you just verb it.
        --- Bucky Katt, Get Fuzzy
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