PEP 234: Iterators
Bjorn Pettersen
BPettersen at NAREX.com
Wed May 2 11:50:37 EDT 2001
> From: Just van Rossum [mailto:just at letterror.com]
> Roman Suzi wrote:
> >
> > On 2 May 2001, Michael Hudson wrote:
> >
> > >"Peter Caven" <p.caven at ieee.org> writes:
> > >
> > >> I really like the idea of returning different kinds of
> iterators for
> > >> dictionaries as described:
> > >>
> > >> > for key, value in dict.iteritems(): ...
> > >> > for value in dict.itervalues(): ...
> > >> > for key in dict.iterkeys(): ...
> > >
> > >Me too.
> >
> > What about xitems, xvalues, xkeys (as in xrange?)
>
> Please read the PEP: iterators largely make these redundant.
> Eg. dict.iteritems()
> doesn't return a list of items (we already have dict.items()
> for that) but an
> _iterator_, allowing you to iterate over the items _without_
> creating a list
> containing them all...
Perhaps it's only a matter of naming? How about itemIterator(),
valueIterator(), etc (or itemiter() if you don't like camelcase)
-- bjorn
More information about the Python-list
mailing list