(why) inconsistent yield/return syntax?

Andrew Koenig ark at research.att.com
Tue Feb 11 00:27:44 CET 2003


Mark> "How do I define a zero-length iterator?"

Mark> def whynot():
Mark>     if True:
Mark>         raise StopIteration
Mark>     yield None

I think I like the following version better:

        def whynot():
                return
                yield None

because it doesn't explicitly depend on StopIteration.

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list