Inheritance problem?

KraftDiner bobrien18 at yahoo.com
Fri Jan 6 13:59:15 EST 2006


So ok I've written a piece of code that demonstrates the problem.
Can you suggest how I change the Square class init?

class Shape(object):
	def __init__(self):
		print 'MyBaseClass __init__'

class Rectangle(Shape):
	def __init__(self):
		super(self.__class__, self).__init__()
		self.type = Rectangle
		print 'Rectangle'

class Square(Rectangle):
	def __init__(self):
		super(self.__class__, self).__init__()
		self.type = Square
		print 'Square'

r = Rectangle()
s = Square()




More information about the Python-list mailing list