(why) inconsistent yield/return syntax?
Andrew Koenig
ark at research.att.com
Tue Feb 11 10:23:51 EST 2003
Alex> If one's happy with any empty _iterator_, though:
Alex> def zeroleniter(): return iter([])
Alex> is clearly simpler and even more concise. I see
Alex> no reason to use any other form.
I do. If I write
def foo():
return
yield None
and I want to come back and change it later so that the sequence it
yields is no longer empty, then it's easy to change.
If, on the other hand, I want to write a function that forevermore
will yield an empty sequence, then I think your suggestion is better.
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list