[Python-3000] Iterators for dict keys, values, and items == annoying :)

Jim Fulton jim at zope.com
Thu Mar 23 20:52:54 CET 2006


Looking over some of the messages in the archives, I saw a reference
to making dict keys, items, and values methods return iterators.  I've heard
Guido mention this in the past.

I'd like to offer a word of caution here.  ZODB has a BTree implemention
that uses iterators for keys, values, and items.  After years of
experience with this, I can definately say that this is very annoying.

A common scenario is that I'm exploring a complex data structure. I give
an expression and repeatedly re-execute, adding a bit to the expression
each time.  I can generally, call up a previous line interactively and
add bits to it.  That is, until I get to a BTree keys (or items or values).
At that point, I have to edit both the beginning and end of the expression
to put a list() call around it.  I then often have to take the list()
call off when I want to look at an individual item in more detail.

If we are dead set on making these methods return iterators, I'd really like
to see a way to either get non-iterators by calling a method or see some
new facilities in the iterators returned.  Perhaps these iterators
could have a method for getting a set of values?

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Python-3000 mailing list