I normally use nested dictionaries, but I'd like to move into classes and objects. I have a list of home work grades that look like:
assignment_name assignment_subject student_name due_date grade grade_pct rank
I'd like to make an object that holds all the students and each students holds all of their assignments details. My dictionary would look like:
homeworks['student_name']['assignment_name'] = {'assignment_subject': 'math', 'due_date': '11/12/13', 'grade': 15, 'grade_pct': 15/20.0, 'rank': 'B'}
Should this be a class within a class?
class Homeworks(object):
def _init_(self):
self.students
class student(object):
def _init_(self,student_name):
self.student_name = student_name
def add_assignment(line):
student.assignment_name = line[0]
student.assignment_subject = line[1]
student.grade = line[4]
I know this isn't right. I don't know if I am on the right track or not. I do need to be able to access the grades for one student. (for assignment in Homeworks['Robbie Michaels'].keys(): print Homeworks['Robbie Michaels'][assignment]['grade']
) I also like to access them using if assignment_subject == 'math'
etc.