"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Do you really need a generator or co-routine to do this? Maybe > you can just use a closure:
For my trivial example, sure -- there are lots of ways to do it. Here's a slightly better example: the `read' method of a file-like object which sequentially joins the contents of a sequence of other file-like objects: @coroutine def read(self, size=-1): data = '' for file in self.files: this = file.read(size - len(data)) data = ''.join([data, this]) while this: if len(data) == size: _, size = (yield data) data = '' this = file.read(size - len(data)) data = ''.join([data, this]) yield data while True: yield '' -Marshall -- http://mail.python.org/mailman/listinfo/python-list