bpo-14050: Note that not all data can be sorted#15381
bpo-14050: Note that not all data can be sorted#15381rhettinger merged 3 commits intopython:masterfrom
Conversation
raulcd
left a comment
There was a problem hiding this comment.
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 <rhettinger@users.noreply.github.com>
https://bugs.python.org/issue14050