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


Groups > comp.lang.python > #20709

Re: storing in list and retrieving.

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.025
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'python': 0.08; 'received:10.50': 0.09; 'stored': 0.13; '4321': 0.16; 'disk.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'open()': 0.16; 'linux': 0.17; 'wrote:': 0.18; 'help.': 0.19; 'received:209.85.210.174': 0.21; 'received:mail- iy0-f174.google.com': 0.21; 'subject:list': 0.21; 'header:In- Reply-To:1': 0.22; 'feb': 0.22; 'figure': 0.26; 'function': 0.27; 'looks': 0.27; "i'm": 0.28; 'script': 0.28; 'message- id:@mail.gmail.com': 0.29; 'print': 0.29; 'pm,': 0.29; 'chris': 0.30; 'thu,': 0.32; 'list': 0.32; 'it.': 0.33; 'object': 0.33; 'file': 0.34; 'to:addr:python-list': 0.35; 'list.': 0.35; 'two': 0.36; 'own,': 0.37; 'run': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'another': 0.37; 'received:209.85': 0.38; 'format': 0.38; 'open': 0.38; 'files': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'header:Received:6': 0.61; 'more': 0.61; 'your': 0.61; 'below': 0.62; '(one': 0.73; 'writing,': 0.93
Received-SPF pass (google.com: domain of rosuav@gmail.com designates 10.50.155.231 as permitted sender) client-ip=10.50.155.231;
Authentication-Results mr.google.com; spf=pass (google.com: domain of rosuav@gmail.com designates 10.50.155.231 as permitted sender) smtp.mail=rosuav@gmail.com; dkim=pass header.i=rosuav@gmail.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=guN1JzWoZTby37X0ZiQelIkOaTH/BTQcuQGxPB0f4Bg=; b=c9DjL8g7Hd/rPhQ8aP2qbc5zWblLkQox1r5RKP90uGzRZ+YlKkFDjBUqmQEGjKJgJt FLWg7X5aLq4/xFqNUaCkouCCNXa3URZkUa5j5jwIbU5Se0LP6BJuN/05HHfE/Q8nakuU DeZSP/4Ql4HWXOrGXboYrtZHkt0lAhvKopbNU=
MIME-Version 1.0
In-Reply-To <CAJ1erZ1qT1ObRWCmJ0bZez++c8EXn772JQgfr4oO3CGRFnwMoA@mail.gmail.com>
References <CAJ1erZ1qT1ObRWCmJ0bZez++c8EXn772JQgfr4oO3CGRFnwMoA@mail.gmail.com>
Date Thu, 23 Feb 2012 17:31:25 +1100
Subject Re: storing in list and retrieving.
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.62.1329978688.3037.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1329978688 news.xs4all.nl 6889 [2001:888:2000:d::a6]:38311
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20709

Show key headers only | View raw


On Thu, Feb 23, 2012 at 5:24 PM, Smiley 4321 <ssmile03@gmail.com> wrote:
> I need to write two file using python script as below -
>
> 1. Store.py: Write a script to store a list say "store_list = ["Apple",
> "Orange", "PineApple". “and so on” ]" to disk.
>
> 2. Retrieve.py: Read the object stored in the ‘Store.py’ file and print the
> contents of this list.
>
> I have to run on Linux with python-2.6.5.

This looks like homework, so I'm just going to give a broad hint.

Figure out a file format (one per line, or pickled, or whatever), then
write one program that writes that format and another that reads it.
The open() built-in function will open files for reading or writing,
so that's a good place to start.

Get as far as you can on your own, and if you get stuck, ask the list
for more specific help. Good luck!

Chris Angelico

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


Thread

Re: storing in list and retrieving. Chris Angelico <rosuav@gmail.com> - 2012-02-23 17:31 +1100

csiph-web