Some problems with classes

ssecorp circularfunc at gmail.com
Mon Sep 1 04:54:39 CEST 2008


also, how does super() work more exactly? I can't get it quite to
work.


class Movie(object):
    def __init__(self, movieId, grades, date):
        self.movieId = movieId
        self.grades = grades
        self.date = date

    def newGrade(self, grade):
        self.grades.append(grade)

    def spam(self):
        print "inherits all the way down?"

    def averageGrade(self):
         return sum(grade for grade in self.grades) / \
                len(self.grades)

class ActionMovie(Movie):
    super(Movie)
    ##def __init__(self, movieId, grades, date, kills):
    ##    self.movieId = movieId
    ##    self.grades = grades
    ##    self.date = date
    ##    self.kills = kills

    def newGrade(self, grade, date):
        self.grades.append(grade)
        self.date = date

    def prd(self):
        print self.date

class Comedy(ActionMovie):
    def __init__(self, movieId, grades, date):
        self.movieId = movieId
        self.grades = grades
        self.date = date

    def donk(self):
        print "im a donkey!"


subclasses has to be indented?
class C(B):
    def meth(self, arg):
        super(C, self).meth(arg)



More information about the Python-list mailing list