0

I have a Time class and a Date class as parent classes , and both of them has the get() method which is Time class gets h/m/s and Date class gets y/m/d . I have Invoice class as child class that inherit from Date and Time class and I want that every object of Invoice class get h/m/s and y/m/d attributes in the moment of creation. all the same as show() method or set() method etc.

I tried :

class Time:
    def get(self):
        #geting the h/m/s

class Date:
    def get(self):
        #geting the y/m/s

class Invoice(Time, Date):
    def __init__(self):
        self.get()

but it only gets from the Time class

Alien
  • 13
  • 3
  • 2
    See https://stackoverflow.com/questions/576169/understanding-python-super-with-init-methods – rkochar Aug 03 '23 at 13:33
  • 3
    An `Invoice` is not a particular kind of `Date`, and it is not a particular kind of `Time`. It is an entirely separate type of object, that happens to *use* a `Date` and a `Time`. There should not be any inheritance going on here, you'd simply have instance attributes (called `date` and `time`, perhaps). – jasonharper Aug 03 '23 at 13:42

0 Answers0