Though I agree with the argument that inexperienced developers are [usually] worse, that's not the case here, unless anyone here is really trying to say the ones arguing for or against "shuffled" are inexperienced. These ad hominem won't bring us anywhere.

No one seem to be arguing if "shuffled" is inconsistent, but the "shuffle" consistency is a subject that didn't reach consensus. And the point now seem to be whether "shuffled" is useful or not. If I understood correctly, that proposal is about writing code in a more functional style (or a expression-oriented programming style), with a pure function for shuffling.

I think there are other related subjects that can be said about sorted/shuffled. For example: why a list? Why not a generator? Something like random.choice is useful to get one single value, but if one just want to see a few random values from a large input without repeating the values, what's the best approach?

Does that mean you expect Python to provide appended() [...] extended() [...]
Doesn't the "+" operator do that?
 
[...] list.cleared()?
Huh? OP is clearly talking about avoiding state, avoiding "in-place" operations. A clear list would be an empty list []. The idea of "popped", "inserted" and "removed" are also simply off-topic.
 

2016-09-07 23:31 GMT-03:00 Steven D'Aprano <steve@pearwood.info>:
On Thu, Sep 08, 2016 at 12:22:28AM +0200, Sven R. Kunze wrote:

> About the confusion of returning None. It's not confusing in the sense
> of "o my god, I did it wrong, I need to learn it", but more, like "I
> used shuffle, BECAUSE it's the only one I could find in a hurry"

Then don't be in such a hurry.

Honestly, there is no substitute for professionalism. Outside of fantasy
novels and movies, there has never been a "ticking time bomb" situation
where a programmer has to write code to shuffle a list in six seconds or
the world will be destroyed. There is *always* time to at least glance
at the docs, and it is never more than a handful of keypresses away in
the interactive interpreter:

    help(random.shuffle)

And if you don't read the docs? Oh well, you find out soon enough once
you actually test your code or have a code review. No harm done.

If the programmer doesn't do *any* of those things -- doesn't read the
docs, doesn't test their code, doesn't do code reviews -- then there's
no hope for them. We could provide shuffled() and shuffle() and they'll
still end up picking the wrong one fifty percent of the time.

"My wild guess of how a function works was wrong, so now I'm cheesed off
that the function doesn't do what I expect" is NOT a good reason to add
things to the standard library.

> I would expect this from
> Python as it already provides both alternatives for sorting".

Does that mean you expect Python to provide appended() as well as
append(), extended() as well as extend(), popped() as well as pop(),
cleared() as well as clear(), inserted() as well as insert(), removed()
as well as remove()?

If your response is to say "Why do we need all those? Why on earth would
anyone need to use list.cleared()?" then perhaps you can now understand
why shuffled() has to prove itself too. Functions don't get added just
because they *can* be added. They have to be worth it. Every function
has costs as well as benefits. Each function adds:

- more code to download, compile, maintain
- more tests
- more documentation
- more for the user to learn
- more choices for the user to decide between
- more complexity
- more risk of bugs

Unless the proposal can demonstrate that the benefit outweighs the
costs, it should not be added. Merely stating that you need it
doesn't demonstate that a four-line helper function at the top of
your module isn't sufficient.

For what's it is worth, if it were *my* call, I'd accept that the costs
of adding this are low, but the benefits are just a *tiny* bit higher.
But that's a judgement call, and if Raymond see the cost:benefit ratio
going the other way, I have no objective argument to change his mind.



--
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/



--
Danilo J. S. Bellini
---------------
"It is not our business to set up prohibitions, but to arrive at conventions." (R. Carnap)