Im attempting to call the grandparent method getColor() from the Class below.
This is the grandparent class in its own file:
class IsVisible(object):
def __init__(self):
pass
white = (255,255,255)
black = (0,0,0)
red = (255,0,0)
blue = (0,0,255)
green = (0,255,0)
def getColor(self):
return self.color
This is the parent class and child class.
from IsVisible import *
class Object(IsVisible):
def __init__(self):
super(Object, self).__init__()
self.posSize = []
def getPosSize(self):
return self.posSize
class Rectangle(Object):
def __init__(self):
super(Rectangle, self).__init__()
self.color = self.blue
self.posSize = [20,50,100,100]
So Im trying to call getColor
by creating an object
rectangle = Rectangle()
and then calling
rectangle.getColor()
However I'm getting an error. Namely:
AttributeError: 'Rectangle' object has no attribute 'getColor'
Now I have no idea how to solve this. I have tried to google "python call grandparent method" but I only get instructions for how to call a method that is overrun... I believe I have stated the inheritance correctly so I don't know what the problem is. Could anyone help me?