import time
class curtime:
timeu = time.asctime(time.localtime(time.time()))
timelist = timeu.split()
day = timelist[0]
month = timelist[1]
date = timelist[2]
time = timelist[3]
year = timelist[4]
def __init__():
timeu = time.asctime(time.localtime(time.time()))
timelist = timeu.split()
day = timelist[0]
month = timelist[1]
date = timelist[2]
time = timelist[3]
year = timelist[4]
def year(self):
print([self.year])
return [self.year]
t1 = curtime()
years = t1.year()
print(years) # this is giving output as [<bound method curtime.year of <__main__.curtime object at 0x00000285753E8470>>]
I want that year(self) function to return the value of year variable but it is returning
> [<bound method curtime.year of <__main__.curtime object at
> 0x00000285753E8470>>]
Any idea how it can be achieved? Also, it will be great if the value can be returned as an integer.
_int_()? Why do you assign twice; one inside function and other outside? There is no need of a class here afterall.