AttributeError: 'Float' object has no attribute 'time'
Question:
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)
Answers:
Don’t use module name time
as keyword here:
def timer(self, time):
if (time.time() - self.lastTime) > self.time:
self.lastTime = time.time()
return True
else:
return False
I guess this is the solution you are looking for:
def timer(self, timeVal):
if (timeVal - self.lastTime) > self.time:
self.lastTime = time.time()
return True
else:
return False
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
I got this error when using it, like that:
time = my_function() *
and in my_function(): …code… time.time() …code…
So, you need to change time *, and it done
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)
Don’t use module name time
as keyword here:
def timer(self, time):
if (time.time() - self.lastTime) > self.time:
self.lastTime = time.time()
return True
else:
return False
I guess this is the solution you are looking for:
def timer(self, timeVal):
if (timeVal - self.lastTime) > self.time:
self.lastTime = time.time()
return True
else:
return False
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
I got this error when using it, like that:
time = my_function() *
and in my_function(): …code… time.time() …code…
So, you need to change time *, and it done