Meta: PEP discussion (was Re: PEP 255: Simple Generators)
tim.one at home.com
Thu Jun 28 06:12:41 CEST 2001
> To behave totally like Icon, it would be necessary
> that given
> def f():
> return 3 + g()
> where g is a generator, and f is called in an iteration
> context, then f would be a generator too.
Actually not! "return" does not supply a generative context in Icon, so
return 3 + g()
produces at most one result regardless of the context f() was called from
and regardless of whether g "wants to" generate more than one result. The
rules in Icon get subtle when crossing expression boundaries. You need
suspend 3 + g()
here instead to make that particular point stick; but then that's like the
PEP 255 example
for x in g():
yield 3 + x
and then f is indeed a generator.
> But then you would have turned Python into Icon. :-)
Well, except for the really *interesting* parts <wink>.
BTW, did you get your Windows install to work??? If so, what was the
More information about the Python-list