Nick Coghlan wrote:
> It ends up looking like this:
> 
>          def __call__(self, value=None):
>              """ Call a generator as a coroutine
> 
>              Returns the first argument supplied to StopIteration or
>              None if no argument was supplied.
>              Raises ContinueIteration with the value yielded as the
>              argument if the generator yields a value
>              """
>              if not self.__started:
>                  raise RuntimeError("Coroutine not started")
>              try:
>                  if exc:
>                      yield_val = self.throw(value, *exc)
>                  else:
>                      yield_val = self.send(value)
>              except (StopIteration), ex:
>                  if ex.args:
>                      return args[0]
>              else:
>                  raise ContinueIteration(yield_val)

Oops, I didn't finish fixing this after I added unwind_call(). Try this 
version instead:

           def __call__(self, value=None):
               """ Call a generator as a coroutine

               Returns the first argument supplied to StopIteration or
               None if no argument was supplied.
               Raises ContinueIteration with the value yielded as the
               argument if the generator yields a value
               """
               try:
                   yield_val = self.send(value)
               except (StopIteration), ex:
                   if ex.args:
                       return args[0]
               else:
                   raise ContinueIteration(yield_val)

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.blogspot.com
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to