[Tutor] How do I save a dictionary to disk? (another newbie question)

Pijus Virketis virketis@fas.harvard.edu
Fri, 11 Jan 2002 00:19:21 -0500


> >    I beat my head against this for a few hours today, went through my
> books
> > and cannot figure out how to store the updated dictionary.
> >    I know this is probably easy stuff but I am completely stumped.
>
> It is as long as you have a lot of spare time and use it to go through the
> Python Library Reference ;) Ah i'm such a nerd.
> You'll want to look at the "shelve" module, I think you'll find it perfect
> for your case. Basically it's an emulation of a dictionary, but with
> persistence added.
> http://www.python.org/doc/current/lib/module-shelve.html
>

Check out the pickle module. That's how you take Python objects and convert
them into byte streams, ready for saving.

-PV