I've written a class called "Time" that does the following: It takes the values of hours, minutes and seconds from the user and prints it in the form hh:mm:ss. If the user does not enter any arguments through the time module, the time object is taken and the values of hours, minutes and seconds are stored in it.
class Time:
import time
obj_time = time.localtime()
def __init__(self, hour=obj_time.tm_hour, minute=obj_time.tm_min, second=obj_time.tm_sec):
self.hour=hour
self.minute=minute
self.second=second
print('Time is: {}:{}:{}'.format(hour,minute,second))
def String_time():
#(my problem)???
Time.__init__(Time)
But I want to write another function called "String_time" for this class, so that by taking the values of hours, minutes and seconds, it will print them in the form of hh:mm:ss But in such a way that if the user enters the hour "5" for example, it will be changed to "05" and then printed.
My problem is that the hour, minute and second values are defined in the __init__
method, how can I use them in the string_time function?