Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41202
| References | <mailman.3223.1363089272.2939.python-list@python.org> <5140b946$0$29965$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| Date | 2013-03-14 11:22 +1100 |
| Subject | Re: Store a variable permanently |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3279.1363220580.2939.python-list@python.org> (permalink) |
On Thu, Mar 14, 2013 at 4:37 AM, Steven D'Aprano
<steve+comp.lang.python@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
>>> 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 ;)
>
> 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).
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: Store a variable permanently Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-03-12 12:54 +0100
Re: Store a variable permanently Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-13 17:37 +0000
Re: Store a variable permanently Chris Angelico <rosuav@gmail.com> - 2013-03-14 11:22 +1100
csiph-web