Talk:A Beginner's Python Tutorial/Classes
Page contents not supported in other languages.
Appearance
From Wikibooks, open books for an open world
The 'DoubleSquare' class is a confusing example as a double square cannot also be a square.
Square inherited class loses description and author attributes
[edit source ]In the Square example, redefining the __init__ function (method) of Shape makes the "description" and "author" attributes to disappear. They should be included in the new __init__ method of Square class.
class Square(Shape):
def __init__(self,x):
self.x = x
self.y = x
self.description = "This shape has not been described yet"
self.author = "Nobody has claimed to make this shape yet"
Another good workaround could be implemented looking at this answer, although maybe it's not for beginners...