[Python-3000] Iterators for dict keys, values, and items == annoying :)

Aahz aahz at pythoncraft.com
Fri Mar 31 03:20:37 CEST 2006


On Thu, Mar 30, 2006, Guido van Rossum wrote:
>
> Java does it this way and I think we can do the same thing:
> 
> keys() and items() return views that behave like sets; values()
> returns a view that behaves like a collection (aka multiset or bag).
> Neither behaves like a list, which means that the order is unspecified
> (even though of course iteration reveals an order, there's nothing
> that says the order needs to remain the same).

What do we want to tell people who have code like this:

keys = d.keys()
keys.sort()

Not so much in terms of the fix, but where/why we drew the line about
what's supported by the value returned by d.keys() and what's not.  I'm
not getting clarity about that from this discussion so far, and I think
it's needed.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Look, it's your affair if you want to play with five people, but don't
go calling it doubles."  --John Cleese anticipates Usenet


More information about the Python-3000 mailing list