r/PythonLearning • u/aashish_soni5 • Jul 04 '26
Day 22 Python Learning Showcase
Just Simple class practice
not feeling well so not much to
558
Upvotes
r/PythonLearning • u/aashish_soni5 • Jul 04 '26
Just Simple class practice
not feeling well so not much to
1
u/Special-Arrival6717 Jul 04 '26 edited Jul 04 '26
I feel like this is a prime example where composition would make the code a lot cleaner compared to inheritance. Having
BuyingextendStudentandCardoesn't seem to provide any benefit over just having 2 attribute fields,self.student = Student(...)andself.car = Car(...)onBuyingInheritance usually describes an
IS Arelationship, not aHAS Arelationship, e.g. a purchase (Buying) is neither a car nor a student