Re: Some problems with classes

2008-09-01 Thread Bruno Desthuilliers
Chris Rebert a écrit : On Sun, Aug 31, 2008 at 6:39 PM, ssecorp [EMAIL PROTECTED] wrote: Why/how is it possible to add variables like this? I don't understand this mechanism: http://docs.python.org/tut/node11.html#SECTION001133 Under the covers, Python objects are implemented

Some problems with classes

2008-08-31 Thread ssecorp
Why/how is it possible to add variables like this? I don't understand this mechanism: http://docs.python.org/tut/node11.html#SECTION001133 class Employee: pass john = Employee() # Create an empty employee record # Fill the fields of the record john.name = 'John Doe'

Re: Some problems with classes

2008-08-31 Thread Chris Rebert
On Sun, Aug 31, 2008 at 6:39 PM, ssecorp [EMAIL PROTECTED] wrote: Why/how is it possible to add variables like this? I don't understand this mechanism: http://docs.python.org/tut/node11.html#SECTION001133 Under the covers, Python objects are implemented using dictionaries, so

Re: Some problems with classes

2008-08-31 Thread ssecorp
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):

Re: Some problems with classes

2008-08-31 Thread ssecorp
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)

Re: Some problems with classes

2008-08-31 Thread ssecorp
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

Re: Some problems with classes

2008-08-31 Thread Michele Simionato
On Sep 1, 3:39 am, ssecorp [EMAIL PROTECTED] wrote: Traceback (most recent call last):   File C:/Python25/Progs//Movie.py, line 42, in module     class ActionComedy(Movie, ActionMovie): TypeError: Error when calling the metaclass bases     Cannot create a consistent method resolution