473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Re: Some problems with classes

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)
Sep 1 '08 #1
1 761
It works when I inherit from 2 classes but not when I inherit from 2
subclasses.
-----------------------------------------------------

from __future__ import division

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, self)
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!"

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

class Animal(object):
def __init__(self, name, weight):
self.name = name
self.weight = weight

def speak(self):
print "speak"

class Vegetable(object):
def __init__(self, name, volume):
self.name = name
self.volume = volume

def split(self):
print "tjoff"

class Vegan(Animal, Vegetable):
#pass
#super()
def __init__(self, name, attacks):
self.name = name
self.attacks = attacks

Sep 1 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ted Byers | last post by:
This is quite frustrating! In the documents, and in the newsgroups, I see simple instructions like the following: =============================================== ==========Beginning of Ray's...
3
by: Peter Blum | last post by:
I have built an assembly (dll) from which I expect third parties to subclass. As a result, when my assembly has a version change, it will cause any third party assembly based on it to break unless...
19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
9
by: jsale | last post by:
Hello, I am having a problem with multiple users using my asp.net application - namely that if each user clicks save at the same time, some, or all, of the users crash out. Do I need to do...
18
by: __PPS__ | last post by:
Hello, I'm a university student and I'm preparing for my final today. I'm reading course notes, I found completely strange piece of code. It makes me laugh, I think the teacher needs to prepare...
1
by: Veerle | last post by:
Hi, I am experiencing a lot of problems with XsdObjectGen. I downloaded the latest version from...
12
by: Janaka Perera | last post by:
Hi All, We have done a object oriented design for a system which will create a class multiply inherited by around 1000 small and medium sized classes. I would be greatful if you can help me...
2
by: Magnus Bergh | last post by:
I got a weird problem with designer. I have created a spearate assembly (DLL) containing my dataset classes and other classes which are shared bewteen the projects in the solution. When I try to...
5
by: Simon | last post by:
I have problem with namespaces. I have a program that consumes the web service and has for instance names space nsProgram. In this program I have defined several classes that I use for storing and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.