[Python-Dev] product()

Barry Warsaw barry at python.org
Thu Oct 23 07:59:11 EDT 2003

On Wed, 2003-10-22 at 21:43, Raymond Hettinger wrote:
> In the course of writing up Pep 289, it became clear that
> the future has a number of accumulator functions in store.

In a crazy, I-haven't-yet-had-my-coffee-yet desperate attempt at
resurrecting PEP 274, what if we made dict (and maybe tuple) accumulator
functions too?  Then if something like dict(genex) would work, how hard
would it be to add some syntactic sugar for that in {genex}?  Aren't we
kind of close already?

>>> from __future__ import generators
>>> def a():
...   for x in 'hello world':
...    yield x
>>> dict([(c, c) for c in a()])
{' ': ' ', 'e': 'e', 'd': 'd', 'h': 'h', 'l': 'l', 'o': 'o', 'r': 'r', 'w': 'w'}

Okay, I promise, I'll shut up now about PEP 274.

pass-the-joe-ly y'rs,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20031023/628f09a2/attachment.bin

More information about the Python-Dev mailing list