Please comment on Draft PEP for Enhanced Generators
Dr. David Mertz
mertz at gnosis.cx
Wed Jan 30 13:32:57 EST 2002
I want to hearily endorse all the elements of Hettinger's PEP proposal.
All of the extensions to generators seem enormously useful, and very
logical extensions of existing capabilities.
Just a couple comments:
The new builtins can obviously be programmed in exactly the way given
in the PEP. In principle, users can start using them today. But
making the functions builtins makes sure that they are familiar more
widely.
The ints() thing can be aliased also, of course. I actually like the
spelling 'ints' or 'ints()' better than 'xrange(sys.maxint)'. But I
can get this just by writing:
ints = xrange(sys.maxint)
or:
ints = lambda: xrange(sys.maxint)
(giving a slight spelling variation in the loop involving the ints).
Here's the part where I might add something helpful to the "Generator
Parameter Passing" suggestion. I have written an article for IBM dW
(in my _Charming Python_ series) that discusses how to simulate full
coroutines using Python 2.2 generators. I think the approach is
rather elegant, actually. However, exotic flow constructs like that I
try out could be expressed even more cleanly with the addition of
Hettinger's suggestion. A non-official draft of my column is at:
http://gnosis.cx/publish/programming/charming_python_b5.txt
(normally I let IBM get through editing and publication before I put
up a personal copy, but this seems germane to the current
discussion... please do not add the URL to any webpage links though,
until it makes it to IBM).
Yours, David...
--
mertz@ | The specter of free information is haunting the `Net! All the
gnosis | powers of IP- and crypto-tyranny have entered into an unholy
.cx | alliance...ideas have nothing to lose but their chains. Unite
| against "intellectual property" and anti-privacy regimes!
-------------------------------------------------------------------------
More information about the Python-list
mailing list