Newby: Dictionaries as file objects?
d_blade8 at hotmail.com
Mon Jun 10 16:24:24 EDT 2002
I agree with David. However, depending on exactly you want to be
doing (and be able to do), you may want to look into the dbm modules
(such as dbm, dbhash, etc.). These are, surprise, database modules
but they allow for the storage of dictionary items. Now, pickle,
shelve, and the like are perhaps the best things for storing Python
objects (let's say a user-created object that contains mixed types)
but the dbm modules have their uses too, based on EXACTLY what you
want to do. Anyway, have fun.
netvegetable <deathtospam43423 at altavista.com> wrote in message news:<Xns9228AB206D06CAusYourStandingInIt at 22.214.171.124>...
> 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?
More information about the Python-list