Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'syntax': 0.03; 'that?': 0.05; 'python': 0.09; '(the': 0.15; 'anyway).': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'repr()': 0.16; 'subject:Store': 0.16; 'subject:variable': 0.16; 'string': 0.17; 'wrote:': 0.17; 'thu,': 0.17; 'shell': 0.18; '>>>': 0.18; 'code,': 0.18; 'trying': 0.21; 'import': 0.21; 'error.': 0.21; 'fairly': 0.21; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; '+0100,': 0.29; "d'aprano": 0.29; 'pickle': 0.29; 'steven': 0.29; 'no,': 0.29; 'writes': 0.30; 'file': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'clear': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'useful': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'more': 0.63; 'here': 0.65; '2013': 0.84; 'actually,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=o8l3ama3He4X8vZEiFYNKS0Mkg3+9FZgU4m1p1V7u9I=; b=dovinxDl9M0VtES7masP4SPKvYlwLJmxndQAV2C1LqeWOQB+YC756pkvhOlmNGr9Xn pmfJxoSM8p0rP2Y4NixIMbnYVH9JIjlGVNQskzYHmW0iBSeAAjbNa1fp4Jusjor/pIVQ KJa+jb7lO+r8/onzZrEUsQhI7LF60Hqa+4VcyxllkbiTP/I+kFrayrKjy/93VIMJhkUs 7SXZSKQqzq7Hz4mTVp/+9aE8zjbMWT047EHGeQpq+9o+/ltWwH0KsB7FPW+MyTLCjl5O pqEEM4BtjBi/OspEzVUoKhjdX6Ybfs+scZFa+2KScLWy06mAgqiRTPDUOHGzzU5ut47V xa0A== MIME-Version: 1.0 X-Received: by 10.220.223.80 with SMTP id ij16mr169134vcb.28.1363220571650; Wed, 13 Mar 2013 17:22:51 -0700 (PDT) In-Reply-To: <5140b946$0$29965$c3e8da3$5496439d@news.astraweb.com> References: <5140b946$0$29965$c3e8da3$5496439d@news.astraweb.com> Date: Thu, 14 Mar 2013 11:22:51 +1100 Subject: Re: Store a variable permanently From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363220580 news.xs4all.nl 6884 [2001:888:2000:d::a6]:45773 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41202 On Thu, Mar 14, 2013 at 4:37 AM, Steven D'Aprano 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