473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Bidirectional Generators

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
4 3065
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Francis Avila | last post by:
Below is an implementation a 'flattening' recursive generator (take a nested iterator and remove all its nesting). Is this possibly general and useful enough to be included in itertools? (I know...
9
by: Francis Avila | last post by:
A little annoyed one day that I couldn't use the statefulness of generators as "resumable functions", I came across Hettinger's PEP 288 (http://www.python.org/peps/pep-0288.html, still listed as...
0
by: Ian Ward | last post by:
I hope to add support for multi-byte encoded and bidirectional text to my curses-based UI library: http://excess.org/urwid/ I would like to support whatever encoding the user likes. Are there...
3
by: Michael Sparks | last post by:
Hi, I'm posting a link to this since I hope it's of interest to people here :) I've written up the talk I gave at ACCU Python UK on the Kamaelia Framework, and it's been published as a BBC...
10
by: Garmt de Vries | last post by:
In an overview of book titles in many languages, which I wrote about in another thread, I've run across a problem with some titles in scripts that are written from right to left, like Arabic and...
8
by: Mateusz Ɓoskot | last post by:
Hi, I know iterator categories as presented by many authors: Stroustrup, Josuttis and Koenig&Moo: Input <---| |<--- Forward <--- Bidirectional <--- Random Output <---|
0
by: Ernst Elzas | last post by:
Hello, I've tried to write a "sed s/original/replacement/g " -like script, but for dealing with situations where both original and replacement contain a mixture of left to right and right to...
9
by: Andreas Prilop | last post by:
Unicode Technical Report #20 http://www.unicode.org/reports/tr20/ considers bidirectional control (formatting) characters as "not suitable for use with markup". This has sometimes been...
13
by: Martin Sand Christensen | last post by:
Hi! First a bit of context. Yesterday I spent a lot of time debugging the following method in a rather slim database abstraction layer we've developed: ,---- | def selectColumn(self,...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.