On Mon, Mar 3, 2008 at 5:29 PM, Dinesh B Vadhia <[EMAIL PROTECTED]> wrote: > > > When you pickle a numpy/scipy matrix does it have to be initialized by > another program? For example: > > Program One: > A = scipy.asmatrix(scipy.empty((i, i)), dtype=int) # initialize > matrix A > <do something with A> > pickle.dump(A) > > Program Two: > pickle.load(A) > > > ... in Program Two, do we need the statement: > > A = scipy.asmatrix(scipy.empty((i, i)), dtype=int) # initialize > matrix A > > before the pickle.load(A)?
No. Neither pickle.load() nor pickle.dump() work like that. The signature of pickle.dump() is pickle.dump(f, obj) and the signature of pickle.load() is obj = pickle.load(f) where `f` is an open file object. There is no need to "pre-declare" `obj` before loading it. > If not, why not and doesn't this make documentation difficult? Not particularly, no. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion