question about generators

Neil Schemenauer nas at
Fri Aug 16 10:35:32 EDT 2002

David Eppstein wrote:
> Tim has proposed a "yield every x()" syntactic-sugar that would allow 
> you to take a generator factory x and use it as if it were a 
> subgenerator.  This seems a reasonable idea, but there is an efficiency 
> argument for having a direct syntax for subgenerators:

I think that depends on how 'yield every' works.  Does it require a
generator-iterator or just any iterator?  Also, does it allow the
generator-iterator to be passed?  For example,

    def grange(n):
        for i in xrange(n):
           yield i

    def grange_wrapper():
        return grange()

    def a():
        yield every grange(10)

    def b():
        yield every grange_wrapper(10)

    def c():
        yield every range(10)
do 'a', 'b', 'c' all work?


More information about the Python-list mailing list