I have a list of objects in python and I want to shuffle them. I thought I could use the
foo = "bar"
a1 = a()
a2 = a()
b = [a1,a2]
random.shuffle should work. Here's an example, where the objects are lists:
from random import shuffle x = [[i] for i in range(10)] shuffle(x) # print x gives [, , , , , , , , , ] # of course your results will vary
Note that shuffle works in place, and returns None.