[New-bugs-announce] [issue25811] return from random.shuffle

Eugene Yunak report at bugs.python.org
Sat Dec 5 15:34:19 EST 2015


New submission from Eugene Yunak:

random.shuffle operates on a list, and changes it in place. I think returning a reference to this list, the same one we got in as the argument, is quite useful and makes it possible to use random.shuffle in chained function calls, e.g.:

somelist.append(''.join(shuffle(list('hello'))))
[i for i in shuffle(list(range(10))) if i%2]

I don't see any good arguments against this, and I couldn't think of a reasonable test for this — is it necessary to test whether the returned reference is the same as the one passed in?

I'm open to any discussion or suggestions you might have.

----------
components: Library (Lib)
files: shuffle_return.patch
keywords: patch
messages: 255971
nosy: Eugene Yunak
priority: normal
severity: normal
status: open
title: return from random.shuffle
type: enhancement
Added file: http://bugs.python.org/file41251/shuffle_return.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25811>
_______________________________________


More information about the New-bugs-announce mailing list