By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,776 Members | 1,238 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,776 IT Pros & Developers. It's quick & easy.

Bidirectional Generators

P: n/a
Okay, I'm almost finished with my first bidirectional generator. By
"almost finished" I mean both that it's almost working, and that I'm
almost about to replace it with a class that works a bit more like
what I currently understand.

Surely some other people have worked with this feature... Are there
any pages that discuss how it's been useful?

No, I don't want to see an implementation of coroutines. I get that
one already. :-)

-Wm
Jul 22 '08 #1
Share this Question
Share on Google+
4 Replies

P: n/a
On Jul 22, 10:07*pm, william tanksley <wtanksle...@gmail.comwrote:
Okay, I'm almost finished with my first bidirectional generator. By
"almost finished" I mean both that it's almost working, and that I'm
almost about to replace it with a class that works a bit more like
what I currently understand.

Surely some other people have worked with this feature... Are there
any pages that discuss how it's been useful?

No, I don't want to see an implementation of coroutines. I get that
one already. :-)

-Wm
What's one of them then?

- Paddy.
Jul 22 '08 #2

P: n/a
Paddy <paddy3...@googlemail.comwrote:
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
Aug 4 '08 #3

P: n/a
On Aug 4, 12:39*pm, william tanksley <wtanksle...@gmail.comwrote:
Paddy <paddy3...@googlemail.comwrote:
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).
Aug 4 '08 #4

P: n/a
Jeff <jeffo...@gmail.comwrote:
william tanksley <wtanksle...@gmail.comwrote:
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.
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).
Ah, nice! I now remember briefly thinking that such a thing should be
possible. Interestingly, I just recently wrote a backtracking search,
so I could have used such a thing -- it's a pity that I didn't
remember about send() while I was doing that.

I may have to alter my design to see what happens.

-Wm
Aug 4 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.