import cPickle as pickle from random import random as rand class Foo(object): def __init__(self, a, b): self.a = a self.b = b def bar(self): return (self.a, self.b) l = [] for i in xrange(10): l.append(FooBaz(rand(), rand())) FILE = open ('list_of_foos.pkl', 'wb') pickle.dump(l, FILE, pickle.HIGHEST_PROTOCOL) FILE.close()