Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Slow down a loop
#1
Hello, is there a way to slow down an entire loop. I don't want:
while True:
    code
    code
    code
    time.sleep(1)
because that's only pausing it for one second. I want the entire script slowed down as shown in this animation I made: https://imgur.com/a/OpdoJKV (The bottom animation is the one that I DO want)

I'm not sure if this is possible but if so, please tell me how to do it. I'm guessing by using the sys module if anything.
Reply
#2
As far as I know, there is no simple way to slow down the interpreter. The question is why would anyone want to do this? If your goal is to make animation with python, it will be done with an event based programming such as in the tkinter or pygame modules. Look for online examples and tutorials on animation with python.
Reply
#3
I have a bug somewhere in a loop, I don't want to ask for the solution cause I want to try and work it out myself but I want to just slow the loop down so I can see what's happening step by step.
Reply
#4
(Apr-23-2018, 04:36 PM)CharlieGallie Wrote: I want to just slow the loop down so I can see what's happening step by step.
What you want is a debugger. Python has an integrated debugger named pdb. There are online tutorials about how to use it. See here or here
Reply


Forum Jump:

User Panel Messages

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