[Tutor] Which should it be, lists, tuples, dictionary or files?

Steven D'Aprano steve at pearwood.info
Mon Jan 2 23:47:42 CET 2012

Ken G. wrote:
> I have been using an Open Office Spreadsheet containing basically, the 
> food name, basic serving amount, calories, sodium and carbohydrate.  
> Daily, I entered the servicing amount being eaten and its calculate the 
> amount of calories, sodium and carbohydrate.  For some odd reason, I 
> kept losing the spreadsheet and its data.
> I am interested in keeping track of the number of calories consumed each 
> day.  Due to losing the spreadsheet data so frequencies, I decided to 
> use Python in keeping track of the basic information and perhaps, keep 
> track of the calories in a file.

If you lose the spreadsheets, what makes you think you won't lose the Python 

> Should the above five elements be stored as a list, tuples, dictionary 
> or file?  I am will familiar with files and have some knowledge of using 
> lists and tuples.  Not too familiar with dictionary.

If you to store the data permanently, it has to go into a file. I suggest you 
learn about INI files to start with. Start by googling for "INI file format" 
and see if it sounds like what you could use.


More information about the Tutor mailing list