New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General FAQ: list.sort() out of date #41392
Comments
http://www.python.org/doc/faq/general.html#why- specifies the idiom: keys = dict.keys()
keys.sort()
for key in keys:
...do whatever with dict[key]... and doesn't mention sorted(). I would suggest the following wording be used: In situations where performance matters, making a copy In Python 2.4 a new builtin - sorted() - has been added. As a result, here's the idiom to iterate over the keys of a for key in sorted(dict.iterkeys()):
...do whatever with dict[key]... |
Logged In: YES Do we want to also reference the 2.3 and earlier idiom? |
Logged In: YES Updated text: In situations where performance matters, making a copy In Python 2.4 a new builtin - sorted() - has been added. As a result, here's the idiom to iterate over the keys of a for key in sorted(dict.iterkeys()):
...do whatever with dict[key]... Versions of Python prior to 2.4 need to use the following idiom: keys = dict.keys()
keys.sort()
for key in keys:
...do whatever with dict[key]... |
Logged In: YES Fixed in rev 1.22 of general.ht. Thanks for the new text! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: