Discuss save high scores? in the Python Programming forum on Dev Shed. save high scores? Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
Time spent in forums: 2 Weeks 6 Days 15 h 17 m 25 sec
Reputation Power: 510
save high scores?
is there anyway to save highscores to a game for example after you finish? i mean so if you set a score for a game, then exit out and come back in the score is still there. i know when you exit out of python all of the variables are reset (at least to my knowledge) but is there anyway around this?
Time spent in forums: 3 Weeks 6 Days 21 h 54 m 27 sec
Reputation Power: 154
You can't save the variables the way you want to. I would suggest saving them in a text file, if you want to make it look somewhat more professional, you can store them in .tmp files in the temporary files directory on the users computer.
Time spent in forums: 4 Days 12 h 36 m 28 sec
Reputation Power: 24
pretty straight forward. Just use pickle to store the veribles or objects. The nicest thing abotu pickle is that you can save anymost everything in python with it. Including veribles, lists, dictionarys, truples, classes, and everything else you can think of
so its quit simple. bascily keep with that syntax. And to not store a dump to a file you can use dumps() witch will just return a string of the pickled object. Then to load that make sure you use loads() instead of load()
i would recommend cPickle tho if you are looking for more speed, you use it EXACTLY the same way and it is like 1000x faster. It is just pickle writen in c