Newby: Dictionaries as file objects?

David LeBlanc whisper at oz.net
Sun Jun 9 03:31:18 EDT 2002


Take a look at Pickle, cPickle and Shelve in the pythondoc - these packages
support saving arbitrary python objects in files (with some restrictions)

HTH,

David LeBlanc
Seattle, WA USA

> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of netvegetable
> Sent: Sunday, June 09, 2002 0:15
> To: python-list at python.org
> Subject: Newby: Dictionaries as file objects?
>
>
> Hi.
>
> I want to be able to store a list on a file object, and I want each list
> item to be a dictionary, complete with its own set of keys and values.
>
> I know I can store a list in a file object, simply by writing
> each item to
> the file as a string , and making sure there's a "\n" character
> at the end
> of it. When I read the file object again, I merely need to open it as
> "open(object).readlines()" and hey presto, my list is back in order.
>
> So is there a way to conveniently store a dictionary in each item as well?
>
> Ta.
>
> --
> netvegetable at excite.com
> --
> http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list