Store a variable permanently

Jean-Michel Pichavant jeanmichel at
Tue Mar 12 12:54:11 CET 2013

----- Original Message -----
> On Mon, 11 Mar 2013 11:19:49 +0100, Jean-Michel Pichavant wrote:
> [...]
> > While your point about security is fair, the others aren't. Pickle
> > uses
> > by default an ascii representation of the data, it's readable and
> > writeable.
> > 
> > import pickle
> > a = 758
> > pickle.dump(a, open('test.pickle', 'w'))
> > !cat test.pickle
> > I758
> > .
> What is that? It's not Python code, !cat test.pickle gives a syntax
> error.

It's a IPython shell session, !cat test.pickle writes the content of that file to stdout. But I have the feeling you already know that ;)

> Pickle is a big module, over 1400 lines, capable of serialising
> almost
> anything. It's a big, powerful hammer for cracking armour-plated
> coconuts. But a single int is pretty much a peanut. Compare pickle's
> 1400
> lines with the dozen or so lines I provided. That is all that I meant
> by
> "overkill".

I would be surprised if the 1400 lines were used to dump an integer. Anyway who cares about the size of the module, a lot of people import sys and os while using only a very subset of it.

And to reuse your analogy, there's nothing wrong cracking a peanut with a hammer as long as you have it in your hands and that it takes absolutely no effort, compared to building your own small peanut cracker. Trying to crack the peanut by landing an airplane on it, that would work *and* be "overkill".

Now about analogies:




The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

More information about the Python-list mailing list