[Tutor] I've run into a jam on the exercise on file I/O

Alan G alan.gauld at freenet.co.uk
Tue Aug 2 09:43:21 CEST 2005

> What if I were to use ID's for the students and use the ID's as the 
> sequence
> index, and link the students and their grades to the IDs?

Its not necessary for what you are doing but it's how you'd normally 
do it
in a relational database, so if you ever needed to turn your file 
program into a full blown database then using IDs would actually help!

The other thing you could do is hold all the data for a single student
in one structure. Thus instead of having lots of lists all linked by
a common index (or ID) you have one collection of students (probably
a dictionary keyed by name) each with all of its own data. This
involves a more complex data structure and is a move in the direction
of object oriented programming but without actual classes and objects
being involved. This might also allow you to use the shelve moduile
to save/restore your data to file easily.

Just a thought,

Alan G. 

More information about the Tutor mailing list