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
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'
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
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):
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)
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
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