FAQ: Learn Python: Classes - Review


#23

One suspects that grade has an attribute we’re not polling.

If it is an instance, then just the name won’t mean much.


#24

Ah yes, I see it should be grade.score. I think there is some confusion over this because the solution given for the exercise defines the method as:

  def add_grade(self, grade):
    if type(grade) is Grade:
      self.grades.append(grade)

when what we really want is:

  def add_grade(self, grade):
    if type(grade) is Grade:
      self.grades.append(grade.score)