storing in list and retrieving.

Chris Angelico rosuav at gmail.com
Thu Feb 23 01:31:25 EST 2012


On Thu, Feb 23, 2012 at 5:24 PM, Smiley 4321 <ssmile03 at 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



More information about the Python-list mailing list