r/PythonLearning • • 3d ago

Python Study Log: Day 22

Post image
5 Upvotes

3 comments sorted by

•

u/Sea-Ad7805 3d ago

Run program above by clicking Memory Graph Web Debugger and see its state change step by step.

2

u/Money_Ad_5277 3d ago

OOP. Cool!

Want to point out something:
Inheritance is wrong. Buying isn't Student nor Car

Better buying class would be

class Buying: # also, naming stuff - hard but worth it
  def __init__(self, buyer: Student, car: Car):
    self._buyer = buyer # also you could implement .copy() method
    self._car = car # .copy()
  def buyer_info(self):
    self._buyer.info()
    self._car.car_info()

1

u/sirah_nzr 3d ago

Keep go