(why) inconsistent yield/return syntax?

Andrew Koenig ark at research.att.com
Mon Feb 10 18:27:44 EST 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