I have a list of objects and I want to shuffle them. I thought I could use the random.shuffle
method, but this seems to fail when the list is of objects. Is the
'print func(foo)' will print the return value of 'func' when called with 'foo'. 'shuffle' however has None as its return type, as the list will be modified in place, hence it prints nothing. Workaround:
# shuffle the list in place
random.shuffle(b)
# print it
print(b)
If you're more into functional programming style you might want to make the following wrapper function:
def myshuffle(ls):
random.shuffle(ls)
return ls