Nov-15-2018, 12:18 PM
I have been losing it completely for the last two hours over this. It has made my project suddenly fail completely.
ALL I WANT IS TO BE ABLE TO PERFORM SIMPLE ARITHMETIC ON A NUMBER RETURNED FROM time.time.
Apologies for the caps there but i have lost my temper really badly on this - EVERY reference states that time.time returns a float number, which suggests it should be ready for trying arithmetic, but every attempt i make to do this ends with an error of multiple different types.
My code should be quite simply recording time to a variable, i know this works, as i print the time frequently and its fine, but when i try to perform arithmetic it fails. First, it states that i am attempting to perform arithmetic on a function, suggesting that instead of actually assigning the value of time.time returned to the variable, it is in fact assigning the variable to be an alias of the function, thereby creating a newly names version of the function instead of performing the function and giving me my value.
I have tried casting its value to a type, both integer and float value, and i have searched the internet extensively, but to no avail.
I apologise that the tone of my message is somewhat angry - i have been beating my head against the wall it feels like for hours, because a function doesnt operate the way the entire internet suggests it should, inclusive of the manual for python.
The code should operate as follows. I am aware that this snippet actually does nothing, i have removed the functional code such that all which remains is the offending article, i have also reformatted it to make sure it is runnable, even if it is useless as this appears.
Thanks in advance for any help offered.
(this actually runs as part of over a thousand lines of code, running inside one of multiple threads... seems very confuising if i posted it all here)
Its using tesseract to acquire some text, which all runs perfectly, the aim here is to check if it has received the same response three times in a row.
I am also very much aware that in this format it would likely create an infinite loop. in the context of the program, this small snippet exists between a carefully laid out set of sleeps to manage my threads, and so the infinite loop should be ignored here.
(currently returning TypeError: unsupported operand type(s) for *: 'builtin_function_or_method' and 'int', which is the first error i got.)
ALL I WANT IS TO BE ABLE TO PERFORM SIMPLE ARITHMETIC ON A NUMBER RETURNED FROM time.time.
Apologies for the caps there but i have lost my temper really badly on this - EVERY reference states that time.time returns a float number, which suggests it should be ready for trying arithmetic, but every attempt i make to do this ends with an error of multiple different types.
My code should be quite simply recording time to a variable, i know this works, as i print the time frequently and its fine, but when i try to perform arithmetic it fails. First, it states that i am attempting to perform arithmetic on a function, suggesting that instead of actually assigning the value of time.time returned to the variable, it is in fact assigning the variable to be an alias of the function, thereby creating a newly names version of the function instead of performing the function and giving me my value.
I have tried casting its value to a type, both integer and float value, and i have searched the internet extensively, but to no avail.
I apologise that the tone of my message is somewhat angry - i have been beating my head against the wall it feels like for hours, because a function doesnt operate the way the entire internet suggests it should, inclusive of the manual for python.
The code should operate as follows. I am aware that this snippet actually does nothing, i have removed the functional code such that all which remains is the offending article, i have also reformatted it to make sure it is runnable, even if it is useless as this appears.
Thanks in advance for any help offered.
(this actually runs as part of over a thousand lines of code, running inside one of multiple threads... seems very confuising if i posted it all here)
Its using tesseract to acquire some text, which all runs perfectly, the aim here is to check if it has received the same response three times in a row.
I am also very much aware that in this format it would likely create an infinite loop. in the context of the program, this small snippet exists between a carefully laid out set of sleeps to manage my threads, and so the infinite loop should be ignored here.
while (active==true): if "Word" in text: temptime=time.time() print("Word Text Found") textcyclelength=int(textcyclelength * 1000) temptime=int(temptime * 1000) temptime=(textcyclelength-temptime) if (textrepeat > 2) and (textcyclelength < 3000): textcyclelength=time.time typing=True texttotype="text1" textrepeats=0 elif (textcyclelength < 3000): textcyclelength=time.time typing=True texttotype="text2" textrepeats=textrepeats+1 elif (textcyclelength > 3000): textcyclelength=time.time typing=True texttotype="text3" textrepeats=0Please help, this is driving me nuts. I just want a simple number...
(currently returning TypeError: unsupported operand type(s) for *: 'builtin_function_or_method' and 'int', which is the first error i got.)