PEP 234: Iterators
Michael Hudson
mwh21 at cam.ac.uk
Wed May 2 09:25:50 EDT 2001
com-nospam at ccraig.org (Christopher A. Craig) writes:
> Just van Rossum <just at letterror.com> writes:
> > Roman Suzi wrote:
> > > 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...
>
> Much as xrange presently doesn't return a list of items, but an object
> that returns the next item with each successive call to __getitem__.
> I think his point was that having methods on the mapping objects named
> xitems, xvalues, and xkeys instead of iteritems, itervalues, and
> iterkeys would be inline with names of the present xrange and
> xreadlines functions.
But .iteritems(), etc. are much better names. So there.
Cheers,
M.
--
If trees could scream, would we be so cavalier about cutting them
down? We might, if they screamed all the time, for no good reason.
-- Jack Handey
More information about the Python-list
mailing list