Hi all. I'm looking at Python for the first time, and using it for an app I'm writing to try it out. I normally use c or perl.
I have a class that has half a dozen or so data fields. It needs to be able to save its data to a text file, in a format that's easy to edit with other tools (vi, perl, etc). And needs to be able to load itself back from disk. I discovered that a dictionary can convert itself into a nice string format that I can save directly to a file. So I thought I could put a dictionary in the class to hold the data, and save the string representation of the dictionary to the file. Each object instance is on a single text line. I created get/set methods for each field to avoid problems if I mis-type the dictionary keys. Now I have a couple of questions: - What is the recommended 'python' way to implement this class? and - If what I'm doing is OK, is there an easy way to load a dictionary from the string representation without parsing the string manually? Thanks for your time! _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
