On 4/1/06, Thomas Lotze <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I wonder what's the reason for iterating over a dict by keys:
>
> >>> for x in {1:"a", 2:"b"}:
> ...     print x
> ...
> 1
> 2
>
> I find it much more intuitive for the values, "a" and "b", to be accessed.
> This is particularly confusing as iterating over tuples, lists and sets in
> the same way does access the values. (It feels like iterating over a list
> l actually iterates over the index values, range(len(l)).) In fact,
> iterating over any container should access the contained values.
>
> The reason I ask this on the python-3000 list is that I wonder whether the
> iterating behaviour of dicts might be changed in Python 3k, so that in the
> above code, foo() would be applied to the dict's values.

Just to confirm what's already been said, this was considered very
carefully and won't change.

--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to