RELEASED: Python 2.2a1

Carsten Gaebler clpy at snakefarm.org
Thu Jul 19 03:26:16 EDT 2001


Guido van Rossum wrote:

> - Iterators (PEP 234) and generators (PEP 255) were added.

First of all let me say: iterators rule! :-) Not being able to memory- and
code-friendly iterate over dictionaries was the one thing where I sometimes
preferred Perl over Python.

However, I'd like to suggest a small syntax enhancement. Additionally to 'for
key in dict:' being equivalent to 'for key in dict.iterkeys():' it would be
really nice to have some magic that makes 'for (key, value) in dict:'
equivalent to 'for (key, value) in dict.iteritems():'.

Perhaps this would resolve the "discussion about whether for x in dict: ...
should assign x the successive keys, values, or items of the dictionary."
mentioned in the PEP?

cg.



More information about the Python-list mailing list