On Mon, 2005-10-24 at 23:55 -0700, Shi Mu wrote: > I got a sample code and tested it but really can not understand the > use of pickle and dump: > > >>> import pickle > >>> f = open("try.txt", "w") > >>> pickle.dump(3.14, f) > >>> pickle.dump([1,2,3,4], f) > >>> f.close()
The pickle module "serializes" python objects. You can "dump" a python object that can later be loaded: >>> x = complex(2,3.5) >>> f = open("cnumber.pickle", "w") >>> import pickle >>> pickle.dump(x, f) >>> f.close() >>> y = pickle.load(file("cnumber.pickle", "r")) >>> y (2+3.5j) -- http://mail.python.org/mailman/listinfo/python-list