Comments in pickles?

Douglas Zongker dougz at cs.washington.edu
Tue Jul 2 22:42:21 EDT 2002


Roy Smith <roy at panix.com> wrote:
: [...]  I want to check those pickles into CVS.

: Our usual practice is to imbed the CVS id string ($Id: ) in every 
: checked-in file as a comment.  Is there any way to do that with a 
: pickle?  Does a comment convention exist which cPickle.load() 
: understands?

It seems that since a pickle might happen to contain spurious
instances of the string "$Id:" (or one of the other things that CVS
replaces), you would want to turn off CVS's keyword replacement for
these files anyway.  (*Especially* if you're writing binary pickles.)

But if you're not going to do that, you could just adopt a convention
where the first line of the file is a comment.  To write one, you open
a file, write the command, and then dump the pickle data.  To read it
back, open the file, read and discard one line, then do a pickle load
on the rest of the file.

dz



More information about the Python-list mailing list