[BangPypers] Pickle multiple objects

Roshan Mathews rmathews at gmail.com
Wed Oct 7 09:53:22 CEST 2009


On Wed, Oct 7, 2009 at 1:14 PM, Aneesh A <aneesh.nl at gmail.com> wrote:
> I have to store high scores, so i pickled a list . after pickling, in append
> mode, load method loads only first object.
> How to retrieve multiple objects??

What does this do:

import cPickle as pickle
list = [ (i, str(i)) for i in range(10) ]
print list
pickle.dump(list, file('dump', 'wb'), -1)
list = pickle.load(file('dump', 'rb'))
print list

Roshan Mathews


More information about the BangPypers mailing list