[Python-Dev] PEP 340 -- concept clarification

Raymond Hettinger python at rcn.com
Tue May 3 17:41:52 CEST 2005

I just made a first reading of the PEP and want to clarify my
understanding of how it fits with existing concepts.

Is it correct to say that "continue" parallel's its current meaning and
returns control upwards (?outwards) to the block iterator that called

Likewise, is it correct that "yield" is anti-parallel to the current
meaning?  Inside a generator, it returns control upwards to the caller.
But inside a block-iterator, it pushes control downwards (?inwards) to
the block it controls.

Is the distinction between block iterators and generators similar to the
Gang-of-Four's distinction between external and internal iterators?

Are there some good use cases that do not involve resource locking?
IIRC, that same use case was listed a prime motivating example for
decorators (i.e. @syncronized).  TOOWTDI suggests that a single use case
should not be used to justify multiple, orthogonal control structures.  

It would be great if we could point to some code in the standard library
or in a major Python application that would be better (cleaner, faster,
or clearer) if re-written using blocks and block-iterators.  I've
scanned through the code base looking for some places to apply the idea
and have come up empty handed.  This could mean that I've not yet
grasped the essence of what makes the idea useful or it may have other
implications such as apps needing to be designed from the ground-up with
block iterators in mind.


More information about the Python-Dev mailing list