6.9.1 Storing data structures in text files

The dump(x) method of file handles is provided as a means of writing a typeable ASCII representation of the object x to file, for later recovery using the load command. It is similar to the pickle() function in Python.

There is no limit to the depth to which it will traverse hierarchically nested data structures, and will produce output of infinite length if there is recursive nesting.

Note that it is not able to store representations of function definitions or file handles, which are stored as null objects; class instances lose their relationship with their parents and are stored as free-standing modules.