About adding a new iterator method called "shuffled"
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
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
participants (2)
-
Aahz
-
Roy Hyunjin Han