PEP 234: Iterators

Just van Rossum just at letterror.com
Wed May 2 14:19:56 CEST 2001


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...

Just



More information about the Python-list mailing list