Python Forum
time.time wont return a useable number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
time.time wont return a useable number
#3
Firstly, thanks for your swift response. :)

What do you mean by refactoring please?

I am a self taught coder so i dont really have much in the way of direction. What i would have wanted to use, before ineffective google searches got involved, is below.

The original code was copied from my current state but the code below is basically what i had to begin with, but threw the same error as above.

Again, simplified to only the relevant parts.

temptime=time.time()
textlooptime=time.time()
textrepeats=0
while (true):
      temptime=textlooptime - time.time()
      if (textrepeats > 2):
             # this is where the catch out responds to 
             # repeated short intervals
             textlooptime=time.time()
             textrepeats=0
      elif temptime > 3:
             # do the first lot - we detected a long 
             # enough interval
             textrepeats = 0
             textlooptime=time.time()
      elif (temptime <= 3):
             # do the second lot, interval too short.
             textrepeats = textrepeats + 1
             textlooptime=time.time()
Clearly, the code is different, but im out and on mobile.
I know my syntax was correct (: etc) on the firstlot because idle wont let it run until thats covered. The code runs on a thread and actually closes the thread when this happens, making the rest of the program go haywire.

I have simplified this way as this is the only change made, and its the only thing im having trouble with.

Thanks again :)

- edited - forgot some declarations
Reply


Messages In This Thread
RE: time.time wont return a useable number - by Nyscersul - Nov-15-2018, 02:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Schedule exit a program at a specific time 4 am every day. chubbychub 3 156 7 hours ago
Last Post: chubbychub
  Filer and sort files by modification time in a directory tester_V 5 384 May-02-2024, 05:39 PM
Last Post: tester_V
Question Convert UTC now() to local time to compare to a strptime() Calab 2 295 Apr-29-2024, 07:24 PM
Last Post: deanhystad
  Date Time Series Help...Please spra8560 2 431 Feb-01-2024, 01:38 PM
Last Post: spra8560
  Python date format changes to date & time 1418 4 714 Jan-20-2024, 04:45 AM
Last Post: 1418
  time difference bettwenn logs enkliy 14 1,154 Nov-21-2023, 04:51 PM
Last Post: rob101
Question Need Help with Vehicle Routing Problem with Time Windows (VRPTW) in Python kasper321421312 1 643 Nov-10-2023, 08:19 PM
Last Post: snippsat
  How do I stream and record at the same time with arducam? traderjoe 0 506 Oct-23-2023, 12:01 AM
Last Post: traderjoe
  i tried to install python for the first time today and pretty certain im being remote brianlj 2 598 Oct-03-2023, 11:15 AM
Last Post: snippsat
  Why wont this path work one way, but will the other way? cubangt 2 704 Sep-01-2023, 04:14 PM
Last Post: cubangt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020