Yielding a chain of values

Michael Hudson mwh at python.net
Tue Aug 30 08:18:59 EDT 2005


Talin <talin at acm.org> writes:

> I'm finding that a lot of places within my code, I want to return the
> output of a generator from another generator. Currently the only
> method I know of to do this is to explicitly loop over the results
> from the inner generator, and yield each one:
>
>         for x in inner():
>             yield x
>
> I was wondering if there was a more efficient and concise way to do
> this. And if there isn't,

Greenlets, perhaps?  (for which, see google).

Cheers,
mwh

-- 
  LINTILLA:  You could take some evening classes.
    ARTHUR:  What, here?
  LINTILLA:  Yes, I've got a bottle of them.  Little pink ones.
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 12



More information about the Python-list mailing list