``pickling'' and ``unpickling''

Lonnie Princehouse finite.automaton at gmail.com
Thu Apr 6 01:36:16 EDT 2006


Pickling is the Python term for serialization.   See
http://en.wikipedia.org/wiki/Serialization

Suppose you want to save a Python object "x" to a file...

output_file = open('my_pickle', 'wb') # open a file

import pickle
pickle.dump(x, output_file)  # write x to the file
output_file.close()

... and to restore x from the file:

input_file = open('my_pickle','rb')
x = pickle.load(input_file)
input_file.close()




More information about the Python-list mailing list