On 04/27/2016 08:49 PM, Christopher Reimer wrote:
> On 4/27/2016 7:00 PM, Michael Torrie wrote:
>> I am guessing that the reason you are storing state as it's own 
>> dictionary is so that you can pass the state itself to the constructor? 
> 
> Someone said it was bad to store the object itself to file (my original 
> plan) and that I should use a dictionary instead. This is my 
> implementation of that idea. However, saving and loading data is far 
> down my to do list.

Pickle should be able to serialize an object that stores state as
attributes, as that's what objects normally do.

But you could also serialize and save the objects yourself manually too.
 In fact if it were me I would save game state to some kind of ini file,
which would mean manually going through each object and writing out the
relevant data to the ini file using the right syntax. And then reverse
the process when restoring from a file.  XML could be another format
used for your file, if you're into that kind of thing.


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to