module looping

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Will Stuyvesant

    module looping

    How to loop without using a looping construct; or a generator
    without "yield".

    ----- file: generatory.py --------------------------------
    import receiver

    maxx = 10

    def send(x):
    if x >= maxx: return
    x = x + 1
    receiver.send(x )

    if __name__ == '__main__':
    receiver.send(1 )
    ----------------------------------------------------------

    ----- file: receiver.py ---------------------------------
    import generator

    def send(what):
    print 'receiver received:', what
    generator.send( what)
    ----------------------------------------------------------
  • David Eppstein

    #2
    Re: module looping

    In article <cb035744.04052 12236.1a1e95c@p osting.google.c om>,
    hwlgw@hotmail.c om (Will Stuyvesant) wrote:
    [color=blue]
    > How to loop without using a looping construct; or a generator
    > without "yield".[/color]

    Seems like it will quickly hit the recursion limit...

    --
    David Eppstein http://www.ics.uci.edu/~eppstein/
    Univ. of California, Irvine, School of Information & Computer Science

    Comment

    • Miklos

      #3
      Re: module looping

      David Eppstein wrote:
      [color=blue]
      > In article <cb035744.04052 12236.1a1e95c@p osting.google.c om>,
      > hwlgw@hotmail.c om (Will Stuyvesant) wrote:
      >[color=green]
      >> How to loop without using a looping construct; or a generator
      >> without "yield".[/color]
      >
      > Seems like it will quickly hit the recursion limit...
      >[/color]
      Yep, that's right. But it's still an interesting* feat. :-)
      * to me, at least

      Best,
      Pm



      --
      --
      Pm

      Comment

      Working...