On 26/08/18 23:38, boB Stepp wrote: > class SolitaireGame(): > def __init__(self, name): > self.name = name
> Say I go with the aforementioned game with 13 separate scores to keep > track of. The names of these games might be "Two_Mastery", > "Three_Mastery", ... , "Ace_Mastery". In principle I want 13 objects > with each one keeping track of each of the above games. Then I might > want to switch to "Spider_Solitaire", keep track of its score, then go > to something else, then back to Mastery, etc. How on earth am I to > generate unique identifiers for each of these SolitaireGame objects in > a rational way, not knowing in advance moment to moment what type of > solitaire game I might be playing? A dictionary of objects keyed by name? If using a GUI add the names to a drop down or listbox to ease later selection. Does that work for you? > between them at will. Of course the intent is to persistently store > these objects on disk upon program closure. Maybe JSON for that? Or even a shelve database? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor