-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-14050: Note that not all data can be sorted #15381
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
bpo-14050: Note that not all data can be sorted #15381
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This note on the documentation tutorial makes a lot of sense to me but shouldn't we say that it would fail when trying to sort?
When I read that this suggested me it wouldn't sort it but not that it would fail when trying to do so:
>>> a.sort()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '<' not supported between instances of 'int' and 'NoneType'
Maybe changing this:
For instance, ``[None, 'hello', 10]`` doesn't sort because integers can't be compared to strings and *None* can't be compared to other types.
for
For instance, ``[None, 'hello', 10]`` will fail when trying to sort because integers can't be compared to strings and *None* can't be compared to other types.
Not sure if in that part of the tutorial is too early to say will raise a TypeError Exception
.
Nonetheless I think is a pretty good addition to the tutorial.
Thanks for the suggestion. To keep the section affirmatively worded, I avoided talking about "failure". And yes, it is too early in the text to go in to specific exceptions. I just want to introduce the concept that not all orderings are defined. |
Thanks @rhettinger for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
GH-15395 is a backport of this pull request to the 3.8 branch. |
(cherry picked from commit 4109263) Co-authored-by: Raymond Hettinger <[email protected]>
(cherry picked from commit 4109263) Co-authored-by: Raymond Hettinger <[email protected]>
https://bugs.python.org/issue14050