Skip to content

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

Merged
merged 3 commits into from
Aug 22, 2019

Conversation

rhettinger
Copy link
Contributor

@rhettinger rhettinger commented Aug 22, 2019

@rhettinger rhettinger requested a review from willingc August 22, 2019 09:18
Copy link
Contributor

@raulcd raulcd left a 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.

@rhettinger
Copy link
Contributor Author

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.

@rhettinger rhettinger merged commit 4109263 into python:master Aug 22, 2019
@rhettinger rhettinger deleted the list_sort_order_requirement branch August 22, 2019 16:11
@miss-islington
Copy link
Contributor

Thanks @rhettinger for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-15395 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 22, 2019
(cherry picked from commit 4109263)

Co-authored-by: Raymond Hettinger <[email protected]>
rhettinger added a commit that referenced this pull request Aug 22, 2019
(cherry picked from commit 4109263)

Co-authored-by: Raymond Hettinger <[email protected]>
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants