Search code examples
pythontimeattributeerror

AttributeError: 'Float' object has no attribute 'time'


I am currently getting this error in my code

AttributeError: 'Float' object has no attribute 'time'

I have not seen an exact instance to mine I have seen some changes to dtype=object but I am unsure how to implement that and why I would need to. This is a pretty straight forward function.

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)

Solution

  • import time
    

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

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