[Python-ideas] Shuffled

Sven R. Kunze srkunze at mail.de
Wed Sep 7 18:22:28 EDT 2016


Maybe, there's a misunderstanding here and I hope I didn't waste too 
much of your and my time.

Not sure where I got this from but my last status was that Arek would 
like to have a "shuffled" function that does exactly what you described. 
Maybe, that doesn't fit the reports description but his pull request 
will tell the truth. :)


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" and 
then ascertain "why the heck is there no alternative returning the 
shuffled result instead of overwriting my list? I would expect this from 
Python as it already provides both alternatives for sorting".


Sven


On 08.09.2016 00:02, Tim Peters wrote:
> [Sven R. Kunze <srkunze at mail.de>]
>> I am not questioning experience which everyone in a team can benefit from.
>>
>>
>> BUT experienced devs also need to recognize and respect the fact that
>> younger/unexperienced developers are just better in detecting
>> inconsistencies and bloody work-arounds. They simply haven't had to live
>> with them for so long. Experienced devs just are stuck in a rut/are
>> routine-blinded: "we've done that for years", "there's no better way".
>>
>>
>> That's the way we do it in our teams. Employing the new guys as some sort of
>> inconsistency detectors. This way, they learn to find their way around the
>> code base and they can improve it by doing so.
>>
>> And I would never allow it in my team, to dismiss this kind of observation
>> from new colleagues. It's invaluable as they will become routine-blinded as
>> well.
> I have been more than willing to discuss it, and I did not close the
> issue report.  I did say I was opposed to it, but that's simply
> because I am, and I explained there too _why_ I was opposed.
>
> Do you have anything to say about the specific proposal?  I doubt
> either of us has found this meta-discussion useful.  I'm still looking
> for a compelling use case.  The only concrete thing anyone has noted
> in `shuffled()`'s favor so far is that sometimes they're surprised by
> the behavior of random.shuffle(list) returning None in an interactive
> shell (noted by you, and by another, and I cheerfully own up to being
> a bit surprised by that too long ago).   But that's an observation
> about `random.shuffle()`, not about the proposed `shuffled()`.
>
>
>>> [...] I would be far more annoyed if, e.g.,
>>>
>>>>>> random.shuffle(some_million_element_list)
>>>   swamped my terminal with mountains of output.
>> But you readily accept this behavior for "sorted"? That makes no sense at
>> all.
> Of course it does.  The only analogy to random.shuffle(big_list)
> returning None that makes a lick of sense here is that big_list.sort()
> also returns None.  IF a `shuffled()` function is introduced, then of
> course it should return its result - just like `sorted()` returns its
> result.
>
>
>>> You can't both behaviors simultaneously, so the status quo wins.
>>> Indeed, the venerable status quo ;-)
>> Nobody said to change "shuffle".
> A verbatim quote from the first message in this thread:
>
>      "Also shuffle() should return self so mutating methods could be chained."




More information about the Python-ideas mailing list