Discussion about PEP 234: iterators
Russell E. Owen
owen at astroNOJNK.washington.edu.invalid
Fri Feb 16 12:41:05 EST 2001
This is in reaction to the new iterator proposal
<http://python.sourceforge.net/peps/pep-0234.html>:
My own reaction is "great!" one misgiving: it does not address a very
common need: to iterate over a dictionary in key-sorted order. Is there
some variant syntax that could handle this case?
(Better yet, and going out on thin ice here, could this be made the
default? I realize that's unlikely and may anger some people to even
suggest it, but I would like to point out that some languages actually
store dictionaries with their keys ordered, so it's at least technically
feasible).
If this issue cannot be addressed, could we at least get "sort" to
return the sorted collection, so one could do:
for key in dictionary.keys().sort():
-- Russell
More information about the Python-list
mailing list