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

Guido van Rossum guido at python.org
Fri Mar 31 03:39:08 CEST 2006


On 3/30/06, Aahz <aahz at pythoncraft.com> wrote:
> 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.

That's a really good point; we need a meta-PEP on how to handle this
kind of issues.

In this particular case I'm convinced that we must allow such code to
break (perhaps silently or painfully); making keys() return an
iterator has been on the Python 3000 agenda for years (pretty much
since iterators were first introduced in Python 2.2).

--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list