Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107748 > unrolled thread

Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

Started byMichael Torrie <torriem@gmail.com>
First post2016-04-27 21:52 -0600
Last post2016-04-27 21:52 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Differences between Class(Object) and Class(Dict) for dictionary usage? Michael Torrie <torriem@gmail.com> - 2016-04-27 21:52 -0600

#107748 — Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

FromMichael Torrie <torriem@gmail.com>
Date2016-04-27 21:52 -0600
SubjectRe: Differences between Class(Object) and Class(Dict) for dictionary usage?
Message-ID<mailman.166.1461815577.32212.python-list@python.org>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web