Bidirectional Generators

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • william tanksley

    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
  • Paddy

    #2
    Re: Bidirectional Generators

    On Jul 22, 10:07 pm, william tanksley <wtanksle...@gm ail.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.

    Comment

    • william tanksley

      #3
      Re: Bidirectional Generators

      Paddy <paddy3...@goog lemail.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

      Comment

      • Jeff

        #4
        Re: Bidirectional Generators

        On Aug 4, 12:39 pm, william tanksley <wtanksle...@gm ail.comwrote:
        Paddy <paddy3...@goog lemail.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('pr ev_token') or reader.send(-1).

        Comment

        • william tanksley

          #5
          Re: Bidirectional Generators

          Jeff <jeffo...@gmail .comwrote:
          william tanksley <wtanksle...@gm ail.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('pr ev_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

          Comment

          Working...