I read this comment today:

When Python decides to add a "direction" parameter to sort() they do something like this:

3.2.7: sort(list)

3.2.8: sort(direction, list)

You can't upgrade from 3.2.7 to 3.2.8 without breaking things, because there is a new parameter. Here's how Peel (and all sane languages) add a "direction" parameter:

Perl 1.2.1: sort(thing)

Perl 1.2.2: sort (thing, direction=ascending)

In the new version, if you don't pass the argument to specify new optional behavior, you get the old behavior by default! That way things don't break.

It's not the first time I hear about this, but it seems really strange. Can somebody explain this decision once and for all? Surely it must have been motivated by some sort of reasoning, and not just "break things on purpose"?

I understand that things will (almost) inevitably break eventually or with major version changes, but this really seems like they intended it. Plus it was a minor version?

  • 6
    I’m voting to close this question because while some implementations of Python are open source, this question not about the open source nature of Python. Jul 28, 2021 at 6:39
  • 1
    @PhillipKendall, perhaps a better match for StackOverflow.
    – vonbrand
    Jul 28, 2021 at 7:05
  • 4
    This just doesn't sound right. Python has a sorted function that receives an iterable, and a list has a sort. Neither of them have a "direction" argument. Where did you see this comment? can you link to a source?
    – Mureinik
    Jul 28, 2021 at 7:43
  • "Plus it was a minor version" - The change that you make between so-called "minor" versions is really up to you. There is the so-called Semantic Versioning specification, but in practice, projects do not really follow the rules of this consistently, if at all.
    – Brandin
    Jul 28, 2021 at 13:22


Browse other questions tagged or ask your own question.