[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] ideas for saving points in games
On Tue, September 25, 2007 12:05 am, Aaron Maupin wrote:
> I used a dictionary as a container for saved game values and pickled the
> dictionary. Maybe not the best way but it worked like a charm.
I find that in at least some cases, pickling is hideously inefficient,
taking on the order of 10 times as much space as a different format.
If you want to store a dictionary, a quick way to do that is to use text,
writing a key:value pair to each line and ignoring lines that start with
"#".
lines = text.split("\n")
key, value = line.split(":")
key = key.rstrip()
value = value.lstrip()
dict[key] = value