On 11/22/2014 05:11 PM, Raymond Hettinger wrote: >> On Nov 22, 2014, at 2:45 PM, Chris Angelico wrote: >> >> Does your middleware_generator work with just a single element, >> yielding either one output value or none? > > I apologize if I didn't make the point clearly. The middleware example was > just simple outline of calling next(), doing some processing, and yielding a > result while letting the StopIteration float through from the next() call.
[middleware example] def middleware_generator(source_generator): it = source_generator() input_value = next(it) output_value = do_something_interesting(input_value) yield output_value The point that Chris made that you should be refuting is this one: >> What happens if do_something_interesting happens to raise >> StopIteration? Will you be surprised that this appears identical to >> the source generator yielding nothing? -- ~Ethan~
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com