save a dictionary in a file
Dan Perl
danperl at rogers.com
Mon Nov 15 14:07:13 EST 2004
Maybe I am missing something, but why don't you just pickle the dictionary
itself and instead you transform it into a list and pickle the list? I
don't know of any restrictions in pickling a dictionary and I do that in
some of my code. I actually pickle a structure of nested dictionaries (ie,
values in the top dictionary are dictionaries themselves, some of their
values are dictionaries, and so on).
Dan
"Luis P. Mendes" <luisXX_lupe2XX at netvisaoXX.pt> wrote in message
news:2vsa8hF2oa58tU1 at uni-berlin.de...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> my program builds a dictionary that I would like to save in a file.
>
> My question is what are the simple ways to do it?
>
> The first solution I've thought of is to transform the dictionary in a
> list, with the key being the first element on that list, and the value
> as the second. Then I could use pickle to do the write and read
> operations. It seems simple and easy.
>
> Is there a more commonly used form to do it, yet in a simple way?
>
> Luis
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFBmPRdHn4UHCY8rB8RApRjAKCF4/pEMbQQ10Quf5CZO/nTL2CpHgCfVWZF
> G36HuPUbLXC1qtB+DP8BhK0=
> =f+vS
> -----END PGP SIGNATURE-----
More information about the Python-list
mailing list