Store a variable permanently
rosuav at gmail.com
Thu Mar 14 01:22:51 CET 2013
On Thu, Mar 14, 2013 at 4:37 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Tue, 12 Mar 2013 12:54:11 +0100, Jean-Michel Pichavant wrote:
>>> > 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
>> 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 ;)
> Actually, no, I don't use IPython and am not familiar with it.
Neither do I, but it's fairly clear what it's trying to do :) But
pickle.dumps achieves the same thing in a much better way (the repr()
of a string is more useful here anyway).
More information about the Python-list