Float" obj has no attr "time

I am getting the following error when attempting to run the above code: AttributeError: 'Float' object has no attribute 'time'. I have seen some solutions that involve changing the dtype to object, but I am unsure why that would be necessary and how to implement it.

import time

class lastCycle():
    def __init__(self):
        self.lastTime = time.time()
        self.time = 0.0

    def timer(self, time):
        if (time.time() - self.lastTime) > self.time:
            self.lastTime = time.time()
            return True
        else:
            return False

statusUpdate = lastCycle().timer(1.0)

The issue is that the variable time is being overwritten by the float value 0.0 in the __init__ method. Therefore, when time.time() is called in the timer method, it is actually trying to call float.time(), which raises the AttributeError.

To resolve this issue, simply change the name of the time variable in the __init__ method to something else, such as self.delay.

Here is the corrected code:

import time

class lastCycle():
    def __init__(self):
        self.lastTime = time.time()
        self.delay = 0.0

    def timer(self):
        if (time.time() - self.lastTime) > self.delay:
            self.lastTime = time.time()
            return True
        else:
            return False

statusUpdate = lastCycle().timer()