On 9/18/07, Alex Martelli <[EMAIL PROTECTED]> wrote: > Rustom Mody <[EMAIL PROTECTED]> wrote: > > > Can someone help? Heres the non-working code > > > > def si(l): > > p = l.next() > > yield p > > (x for x in si(l) if x % p != 0) > > > > There should be an yield or return somewhere but cant figure it out > > Change last line to > > for x in (x for x in si(l) if x % p != 0): yield x
Thanks but why does (yield(x) for x in si(l) if x % p != 0) not work? I would have expected generator expression to play better with generators. More generally, if one wants to 'splice in' a generator into the body of a generator, is there no standard pythonic idiom? -- http://mail.python.org/mailman/listinfo/python-list