Mar-06-2023, 03:21 PM
(This post was last modified: Mar-06-2023, 03:34 PM by deanhystad.)
It is saying 4 because it requires 4. Clock.set_time() is an instance method. The first argument must be an instance of Clock. You are treating it like a static method.
I would rename this method __str__:
I would rename this method __str__:
def get_time(self): return '{:02d}:{:02d}:{:02d}'.format(self.hours, self.minutes, self.seconds)I would also use f'string formatting because format() is old and not great, and also because you use f'string formatting everywhere else in your program.
def __str__(self): return f'{self.hours:02d}:{self.minutes:02d}:{self.seconds:02d}'But I would not use f'string formatting here.
print(f'Updating RTC...')And I would use unpacking here:
year = cet[0] month = cet[1] day = cet[2] hours = cet[3] minutes = cet[4] seconds = cet[5] weekday = cet[6]
year, month, day, hours, minutes, seconds, weekday, *_ = cet