
On Thu, Aug 12, 2010 at 8:42 AM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
Nick Coghlan wrote:
You want more than the iterator protocol - you want the whole generator API (i.e. send() and throw() as well as __next__()).
I can't see why that should be necessary. A 'yield from' manages to degrade gracefully when given something that only supports next(), and there's no reason a cocall can't do the same.
Without send() and throw(), an object is just an iterator, never a cofunction (as there is no way for it to make cooperative calls - you need the extra two methods in order to receive the results of any such calls). Implementing __cocall__ without yourself being able to make cooperative calls doesn't make any sense. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia