question about generators
Duncan Booth
duncan at NOSPAMrcp.co.uk
Wed Aug 21 10:07:09 EDT 2002
Andrew Koenig <ark at research.att.com> wrote in
news:yu994rdo1hvd.fsf at europa.research.att.com:
> Delaney> However, in neither case would you be able to use
>
> Delaney> yield every <seq>
>
> def product(s, *sets):
> if not sets:
> yield every [(x,) for x in s]
> else:
> subproduct = list(product(*sets))
> yield every [(x,) + t for x in s for t in subproduct]
>
> I should think that would work as long as "yield every" takes an
> iterable rather than just a generator.
But this defeats the whole point of using a generator as it builds a
complete list of results every time.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list