From 426e8ab2d2be906eb22b5830cb191f6b6673c07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D8=A3=D8=AD=D9=85=D8=AF=20=D8=A7=D9=84=D9=85=D8=AD=D9=85?= =?UTF-8?q?=D9=88=D8=AF=D9=8A=20=28Ahmed=20El-Mahmoudy=29?= Date: Wed, 18 Mar 2026 09:43:07 +0100 Subject: [PATCH] No need to define __init__ in sub-classes --- ch09-objects/e43b1_legged_animals.py | 30 +++------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/ch09-objects/e43b1_legged_animals.py b/ch09-objects/e43b1_legged_animals.py index aa8e6eb..df576a1 100755 --- a/ch09-objects/e43b1_legged_animals.py +++ b/ch09-objects/e43b1_legged_animals.py @@ -15,46 +15,22 @@ def __repr__(self): class TwoLeggedAnimal(Animal): - def __init__(self, color): - super().__init__(color) - self.number_of_legs = 2 - + number_of_legs = 2 class FourLeggedAnimal(Animal): - def __init__(self, color): - super().__init__(color) - self.number_of_legs = 4 - + number_of_legs = 4 class ZeroLeggedAnimal(Animal): - def __init__(self, color): - super().__init__(color) - self.number_of_legs = 0 - + number_of_legs = 0 class Wolf(FourLeggedAnimal): """Class for creating 4-legged wolves of any color""" - def __init__(self, color): - super().__init__(color) - - class Sheep(FourLeggedAnimal): """Class for creating 4-legged sheep of any color""" - def __init__(self, color): - super().__init__(color) - - class Snake(ZeroLeggedAnimal): """Class for creating 0-legged snakes of any color""" - def __init__(self, color): - super().__init__(color) - - class Parrot(TwoLeggedAnimal): """Class for creating 2-legged parrots of any color""" - - def __init__(self, color): - super().__init__(color)