[Tutor] Saving data to be retrieved later.

Alan Trautman ATrautman@perryjudds.com
Fri Feb 21 11:49:02 2003


Chris Bailey wrote:
>  Hey everyone, I'm a bit new to python, and I don't know much more than 
> the basics of programming in general.
> I'm trying to find a bit of help, but websites/tutorials haven't been 
> very informative in the ways I need them to be.
> Basically what im trying to do, is save a bunch of statistics 
> to seperate files, so they can be called on later. If
> you are familiar with muds, i'm trying to work with pfiles. I just 
> thought I would make a single player text based
> game for my friends and I to play. I have some neat ideas, and I think I 
> know how to implement them, But I
> will of course need a way to save our characters! :) 


I too am working on a similar project and the ability to save and lookup
information in the file is important but so is the ability to refer to a
dictionary of what that attribute means. IE .. storing <spell>fireball<spell
level>4</spell level></spell> for the character is only useful if can then
look up somewhere in your program what to do with the fireball spell. 

The documentation style I used above is an example of XML notation. which
the pyXML library seems (I am early in trying this out) to do a good job of
referencing. The other advantage is using files for everything is pretty
slow. This is where using pickle and fast items like the python dictionary
may also be useful depending on the game style and level of complexity.

For my game, which is non-thumb speed dependant, I'm trying to use XML
indices .


HTH,

Alan


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor