[Python-3000] Iterators for dict keys, values, and items == annoying :)
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Mar 31 04:05:11 CEST 2006
Aahz wrote:
> What do we want to tell people who have code like this:
>
> keys = d.keys()
> keys.sort()
I think the view returned in this case should be
immutable, so that the above fails. Then we tell
them to replace it with
keys = sorted(d.keys())
In general, where we're changing the semantics of
an existing method to return a view instead of a
new object, the view returned should be immutable.
--
Greg
More information about the Python-3000
mailing list