Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41116

Re: Store a variable permanently

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=776bc1e6e=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'lines,': 0.05; 'sys': 0.05; 'that?': 0.05; 'ascii': 0.07; 'url:blog': 0.09; 'python': 0.09; 'subset': 0.09; 'anyway': 0.11; '1400': 0.16; 'big,': 0.16; 'cares': 0.16; 'dump': 0.16; 'integer.': 0.16; 'landing': 0.16; 'readable': 0.16; 'subject:Store': 0.16; 'subject:variable': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'module,': 0.17; 'shell': 0.18; 'code,': 0.18; 'trying': 0.21; 'import': 0.21; 'error.': 0.21; 'meant': 0.21; 'cheers,': 0.23; 'to:2**1': 0.23; 'header:In- Reply-To:1': 0.25; 'lines': 0.28; '+0100,': 0.29; 'pickle': 0.29; 'surprised': 0.29; 'writes': 0.30; 'point': 0.31; 'file': 0.32; '-----': 0.32; 'int': 0.33; 'to:addr:python-list': 0.33; 'wrong': 0.34; 'compared': 0.35; 'data,': 0.35; 'but': 0.36; 'compare': 0.36; 'thank': 0.36; 'uses': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'nothing': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'takes': 0.39; 'your': 0.60; 'you.': 0.61; 'received:194': 0.61; 'capable': 0.63; 'url:p': 0.63; 'information': 0.63; 'person,': 0.65; 'disclose': 0.69; 'notice:': 0.71; 'privileged.': 0.72; 'absolutely': 0.84; '2013': 0.84; 'hammer': 0.84; 'dozen': 0.91; 'medium.': 0.91; 'hands': 0.97
X-IronPort-AV E=Sophos;i="4.84,830,1355094000"; d="scan'208";a="1276574"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Tue, 12 Mar 2013 12:54:11 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Steven D'Aprano <steve+comp.lang.python@pearwood.info>, python-list@python.org
In-Reply-To <513f00cb$0$29965$c3e8da3$5496439d@news.astraweb.com>
Subject Re: Store a variable permanently
MIME-Version 1.0
X-Mailer Zimbra 7.2.2_GA_2852 (ZimbraWebClient - GC7 (Linux)/7.2.2_GA_2852)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3223.1363089272.2939.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363089272 news.xs4all.nl 6918 [2001:888:2000:d::a6]:37749
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41116

Show key headers only | View raw


----- 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 ;)

[snip] 
> 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:
http://www.linguistrix.com/blog/?p=456

Cheers,

JM







-- IMPORTANT NOTICE: 

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.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


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