generators improvement
Duncan Booth
duncan at NOSPAMrcp.co.uk
Tue Aug 19 04:07:40 EDT 2003
Oleg Leschov <kalmas at udm.ru> wrote in
news:bhtiij$psc$2 at ocasysi.rubbernet.net:
> What needs to be done is to allow yield return something - whatever was
> passed to the .next() thing from caller..
> Easy and obvious, isn't it? So is there any principal problem with this
> idea that would prevents its implementation?
Please read PEP 288, http://www.python.org/peps/pep-0288.html
in particular the section:
> Rejected Alternative
> One idea for passing data into a generator was to pass an argument
> through next() and make a assignment using the yield keyword:
>
> datain = yield dataout
> . . .
> dataout = gen.next(datain)
>
> The intractable problem is that the argument to the first next() call
> has to be thrown away, because it doesn't correspond to a yield
> keyword.
--
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