[Python-3000] Iterators for dict keys, values, and items == annoying :)
barry at python.org
Fri Mar 24 16:36:41 CET 2006
On Fri, 2006-03-24 at 07:26 -0800, Guido van Rossum wrote:
> On 3/24/06, Barry Warsaw <barry at python.org> wrote:
> > On Thu, 2006-03-23 at 17:06 -0800, Guido van Rossum wrote:
> > > The pattern with the 'empty' flag is only needed when due to API
> > > constraints you have only got an iterator.
> > Which can happen quite often actually. Perhaps making the original
> > object available as an attribute of the iterator can help in those
> > situations though.
> It can't work, at least not in general. How do you do this if the
> iterator is a generator? Or an infinite sequence? Or a filter? It
> can't be made part of the iterator protocol. You can design your own
> extension of the iterator protocol, but then it wouldn't accept
> arbitrary iterators any more.
Yes, absolutely true. I wasn't really proposing a change to the generic
iterator protocol, just suggestion something "one" could do if "one"
needed that functionality (although an agreed upon convention would make
it somewhat more general).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 309 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-3000/attachments/20060324/0e20f6e5/attachment.pgp
More information about the Python-3000