About adding a new iterator method called "shuffled"

24 Mar
2009
24 Mar
'09
10:48 a.m.
I know that Python has iterator methods called "sorted" and "reversed" and these are handy shortcuts.
Why not add a new iterator method called "shuffled"?
for x in shuffled(range(5)): print x 3 1 2 0 4
Currently, a person has to do the following because random.shuffle() does not return the actual shuffled list. It is verbose.
import random x = range(5) random.shuffle(x) for x in x: print x

24 Mar
24 Mar
10:58 a.m.
New subject: About adding a new iterator method called "shuffled"
On Tue, Mar 24, 2009, Roy Hyunjin Han wrote:
I know that Python has iterator methods called "sorted" and "reversed" and these are handy shortcuts.
Why not add a new iterator method called "shuffled"?
Please do not post ideas like this to python-dev, please use python-ideas
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"Programming language design is not a rational science. Most reasoning
about it is at best rationalization of gut feelings, and at worst plain
wrong." --GvR, python-ideas, 2009-3-1
5302
Age (days ago)
5302
Last active (days ago)
1 comments
2 participants
participants (2)
-
Aahz
-
Roy Hyunjin Han