"Wayne" <sri...@gmail.com> wrote
My favorite example (and the easiest to understand) deals with shapes:
class Shape:
def __init__(self):
self.sides = 0
self.area = 0
class Triangle(Shape):
Shape.__init__(self)
def __init__(self, base=0, height=0):
self.sides = 3
self.area = base/2*height
Shouldn't the Shape.__init__() call be inside the constructor?
Or is there some deep subtle thing going on here that I'm missing?
Also how does subclassing Shape add any value here since
we just create local instance vars for sides and area anyway
if they don't already exist?
Or is this a case of simplifying an example one step too far?
Confusedly,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor