Douglas Alan wrote: > "Terry Reedy" <[EMAIL PROTECTED]> writes: > >> Cetainly, if <yield_all >> iterator> == <for i in iterator: yield i>, I don't see how anything >> is gained except for a few keystrokes. > > What's gained is making one's code more readable and maintainable, > which is the one of the primary reasons that I use Python.
On of the reasons why Python is readable is that the core language is comparatively small. Adding a new reserved word simply to save a few characters is a difficult choice, and each case has to be judged on its merits, but it seems to me that in this case the extra syntax is a burden that would have to be learned by all Python programmers with very little benefit. Remember that many generators will want to do slightly more than just yield from another iterator, and the for loop allows you to put in additional processing easily whereas 'yield_all' has very limited application e.g. for tok in tokenstream(): if tok.type != COMMENT: yield tok I just scanned a random collection of my Python files: out of 50 yield statements I found only 3 which could be rewritten using yield_all. -- http://mail.python.org/mailman/listinfo/python-list