Jim Jewett wrote:
I still don't see why it needs to be a return statement. Why not make
the intent of g explicit
def g():
yield 42
raise StopIteration(43)
Because it would be tedious and ugly, and would actually make
the intent *less* clear in the intended use cases. When
writing a suspendable function, you're not thinking about
iteration. You're thinking about writing a function that
performs some computation and possibly returns a value
when finished.
Have you seen my multithreaded server example? Do you
really think the intent of the code would be any clearer
if all the returns were replaced by raising StopIteration?
--
Greg
_______________________________________________
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