[Python-iterators] RE: Meta: PEP discussion (was Re: PEP 255: Simple Generators)
Gordon McMillan
gmcm at hypernet.com
Thu Jun 21 17:46:53 EDT 2001
Steven D. Majewski wrote:
> My 'suspend value' actually got transformed into returning the
> tuple
> (value, suspended-frame), so to use it in a loop required
> something
> like:
>
> iterf = function # don't mung up the global name
> while 1:
> value, iterf = iterf( args... )
> ... # first time, call the function
> # all others, call the suspended activation frame
Actually, that's almost exactly what a lot of my Stackless
code looks like. While not exactly pretty, it has the advantage
that you can return/suspend/yield (value, None) to signal
you're done. I acquired the habit way back when Stackless
had a leak in the presence of exceptions crossing
continuation boundaries, but grew to like it.
- Gordon
More information about the Python-list
mailing list