[Tutor] How to have unique identifiers for multiple object instances of a given class?

boB Stepp robertvstepp at gmail.com
Mon Aug 27 21:53:48 EDT 2018


On Mon, Aug 27, 2018 at 3:44 AM Alan Gauld via Tutor <tutor at python.org> wrote:
>
> On 27/08/18 04:58, boB Stepp wrote:

> >> Maybe JSON for that? Or even a shelve database?
> >
> > I plan to keep this simple.  I will use a ".cfg" file to store game
> > configuration information and a ".csv" file to store the actual
> > records of hands played.  But I will have to be careful how I generate
> > the base filenames to avoid duplicates and potential nasty
> > user-generated names.  Though this project is only meant for my use
>
>
> If you go with a single JSON file or shelve you have
> no worries about name clashes. JSON is specifically
> designed to store multiple complex object records.
> And it retains the readability of CSV (unlike shelve).

Wouldn't a single JSON file be wasteful?  If I used this program for a
couple of years or so and habitually played a lot of solitaire, that
would be a lot of stuff to load into RAM when on any given solitaire
session I might only play one to three kinds of solitaire.  But
perhaps I am misunderstanding JSON's capabilities as I only have a
cursory knowledge of it from considering it for other projects.

OTOH, even if I loaded into RAM all games I might have ever played I
doubt I would stress out my RAM capacity, so perhaps this is a
non-issue for this type of program on any modern computer.


-- 
boB


More information about the Tutor mailing list