> Based on both replies I got, JSON is what I will use. > > I do need the keys in the dictionary to be numerals, specifically they are > integers. > > I believe after I load a stored pt_table, I can use this script to convert > the keys back to integers. > > pt_table = dict((int(key), value) for key, value in pt_table.items()) > > Please correct me if there is something wrong with that or if there's > something else I should now about converting the keys to ints after reading > the stored data.
Hi Colby, Yes, this looks ok to me. I think we can also express it as a dictionary comprehension. (https://docs.python.org/3/tutorial/datastructures.html#dictionaries) pt_table = {int(key): value for key, value in pt_table.items()} I think the dictionary comprehension approach is slightly more idiomatic, but what you've got looks ok too. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor