Results 1 to 6 of 6

Thread: How to make python prog to wait some time

  1. #1
    Join Date
    Jan 2008
    Location
    Whenever the food is.
    Beans
    1,203
    Distro
    Kubuntu

    How to make python prog to wait some time

    How do I make my python program to wait some time (several seconds)?
    Like this:
    Code:
    print & do stuff
    ...
    
    wait 6 seconds
    
    ...
    continue doing stuff
    Keyboard not found!

    Press any key to continue...

  2. #2
    WW is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Oct 2004
    Beans
    1,532

    Re: How to make python prog to wait some time

    You can use the sleep function in the time module. E.g.
    Code:
    import time
    
    print "This"
    time.sleep(6)
    print "and that."

  3. #3
    Join Date
    Jan 2008
    Location
    Whenever the food is.
    Beans
    1,203
    Distro
    Kubuntu

    Re: How to make python prog to wait some time

    Thanks. It works.
    Keyboard not found!

    Press any key to continue...

  4. #4
    Join Date
    Jan 2008
    Location
    Whenever the food is.
    Beans
    1,203
    Distro
    Kubuntu

    Re: How to make python prog to wait some time

    Quote Originally Posted by WW View Post
    You can use the sleep function in the time module. E.g.
    Code:
    import time
    
    print "This"
    time.sleep(6)
    print "and that."
    Oh wait, how can I do that in milliseconds? If I want it to sleep for 200 milliseconds, will I type in 0.2?
    Keyboard not found!

    Press any key to continue...

  5. #5
    Join Date
    Jun 2006
    Location
    $ pwd _
    Beans
    3,999
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to make python prog to wait some time

    Code:
    sleep(...)
        sleep(seconds)
    
        Delay execution for a given number of seconds.  The argument may be
        a floating point number for subsecond precision.

  6. #6
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    5,745
    Distro
    Xubuntu 15.04 Vivid Vervet

    Re: How to make python prog to wait some time

    Oh wait, how can I do that in milliseconds? If I want it to sleep for 200 milliseconds, will I type in 0.2?
    Yes. I guess the resolution depends on the OS though.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •