Multiple Inheritence and data attributes

wittempj@hotmail.com martin.witte at gmail.com
Fri May 6 17:49:03 EDT 2005


Two things:
- A call to super doesn't make senseif a class is not derived, and
class b seems superfuous.
- Code below is a working example of your code, the way you did it it
generates an error.

-#!/usr/bin/env python
-class A(object):
-    def __init__(self):
-        super(A, self).__init__()
-        self.dog = "fluffy"
-    def changeDog(self):
-        self.dog = "spike"

-class B(object):
-    def __init__(self):
-        super(B, self).__init__()

-class C(A, B):
-    def __init__(self):
-        super(C, self).__init__()
-    def printDog(self, cls):
-        print cls.dog

-c = C()
-c.printDog(c)
-c.changeDog()
-c.printDog(c)

martin at ubuntu:~$ ./test.py
fluffy
spike
martin at ubuntu:~$




More information about the Python-list mailing list