[Python-Dev] yield back-and-forth? (original) (raw)
Edward C. Jones edcjones at comcast.net
Fri Jan 20 20:51:39 CET 2006
- Previous message: [Python-Dev] yield back-and-forth?
- Next message: [Python-Dev] [Python-checkins] r42116 - python/branches/release24-maint/Lib/unittest.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum <guido at python.org> wrote:
The discussion about PEP 343 reminds me of the following. Bram Cohen pointed out in private email that, before PEP 342, there wasn't a big need for a shortcut to pass control to a "sub-generator" because the following for-loop works well enough:
def main_generator(): ... for value in sub_generator(): yield value
This is an important programming trick. It allows recursive use of generators for walking trees, etc. See the source code for os.walk for an example.
- Previous message: [Python-Dev] yield back-and-forth?
- Next message: [Python-Dev] [Python-checkins] r42116 - python/branches/release24-maint/Lib/unittest.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]