Bidirectional Generators

Jeff jeffober at gmail.com
Mon Aug 4 18:45:20 CEST 2008


On Aug 4, 12:39 pm, william tanksley <wtanksle... at gmail.com> wrote:
> Paddy <paddy3... at googlemail.com> wrote:
> > What's one of them then?
>
> I'm sorry, I don't know what you mean.
>
> Meanwhile, more pertinently: I did get my generator working, and then
> I replaced it with a class that did the same thing in less than a
> quarter of the number of lines. So... I'm not going to worry about
> that anymore. My use case obviously wasn't the right one for them.
>
> I'm still curious, though, whether anyone's written any code that
> actually uses yield _and_ send() to do anything that isn't in the
> original PEP.
>
> > - Paddy.
>
> -Wm

I have.  An iterator that could backtrack itself without the user
having to remember previous states.  It would just send back something
like reader.send('prev_token') or reader.send(-1).



More information about the Python-list mailing list