Inheritance problem?

Scott David Daniels scott.daniels at acm.org
Fri Jan 6 15:24:34 EST 2006


KraftDiner wrote:
> 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__()
		super(Rectangle, self).__init__()    # XXX fixed
> 		self.type = Rectangle
> 		print 'Rectangle'
> 
> class Square(Rectangle):
> 	def __init__(self):
> #		super(self.__class__, self).__init__()
		super(Square, self).__init__()    # XXX fixed
> 		self.type = Square
> 		print 'Square'
> 
> r = Rectangle()
> s = Square()
> 


-- 
-Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list