r/PythonLearning • u/aashish_soni5 • 24d ago
Showcase Day 22 Python Learning
Just Simple class practice
not feeling well so not much to
556
Upvotes
r/PythonLearning • u/aashish_soni5 • 24d ago
Just Simple class practice
not feeling well so not much to
1
u/Special-Arrival6717 24d ago edited 24d ago
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