Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Chris Angelico
On Fri, Jun 20, 2014 at 12:33 PM, Terry Reedy wrote: > Most any* console script runs fine** in Idle once you load it into the > editor and press F5. Prompts and prints go the shell window (default blue on > white) and input comes from the same (default black on white). I figured it'd be easy, jus

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Terry Reedy
On 6/19/2014 3:42 AM, Chris Angelico wrote: On Thu, Jun 19, 2014 at 5:18 PM, Christian Gollwitzer wrote: My advice: 1) First try parsing the command line. (Example: All Unix tools) 2) If you require more interaction and maybe state preservation, just write a couple of functions and run it i

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Chris Angelico
On Fri, Jun 20, 2014 at 3:17 AM, Christian Gollwitzer wrote: > While I don't understand the purpose of the program (is it a game?), it > shows exactly why this is a bad idea. It's a tool for calculating stuff about railway tracks. Never mind about the details of what it does with the info, but th

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Christian Gollwitzer
Am 19.06.14 09:42, schrieb Chris Angelico: On Thu, Jun 19, 2014 at 5:18 PM, Christian Gollwitzer wrote: Am 19.06.14 01:38, schrieb Chris Angelico: a good console UI just requires this: something = raw_input("Enter something: ") print("Result: "+result) That is actually one of the worst co

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Marko Rauhamaa
Chris Angelico : > Yeah, I think [raw_]input() isn't so bad after all. I have never used it. I *have* used getpass.getpass(). Unfortunately, it doesn't have a corresponding prompt and raw input variant so I've had to essentially copy over getpass() code and modify that: fd = os.open('/dev/tt

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Chris Angelico
On Thu, Jun 19, 2014 at 5:18 PM, Christian Gollwitzer wrote: > Am 19.06.14 01:38, schrieb Chris Angelico: > >> a good console UI just requires this: >> >> something = raw_input("Enter something: ") >> print("Result: "+result) > > > That is actually one of the worst console UIs possible > > My

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Christian Gollwitzer
Am 19.06.14 01:38, schrieb Chris Angelico: a good console UI just requires this: something = raw_input("Enter something: ") print("Result: "+result) That is actually one of the worst console UIs possible. Almost all beginner's courses start with programs like that, requiring the user to key

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-18 Thread Chris Angelico
On Thu, Jun 19, 2014 at 11:41 AM, crow wrote: > Thanks for the suggestion. > For my script, I want to download a picture from internet & show it in a > window, that's why I use wxPython. > > Well, I think I may can avoid sleep in wxPython in 2 ways: > 1. Use web.py, let python do backend work, le

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-18 Thread crow
Hi, Chris Thanks for the suggestion. For my script, I want to download a picture from internet & show it in a window, that's why I use wxPython. Well, I think I may can avoid sleep in wxPython in 2 ways: 1. Use web.py, let python do backend work, let browser show me everything. As you suggeste

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-18 Thread Chris Angelico
On Thu, Jun 19, 2014 at 1:24 AM, crow wrote: > Here is a sample code that can reproduce this issue, you need to wait for it > to run for a while. > ** > import time > import threading > import wx > > def sleep(): > while True: > t = time.time() > time.sleep(1)

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-18 Thread crow
Hi, Chris & Marko Thanks for your reply. I find the reason why my time.sleep take longer time. In my script, I use wxPython to build up my GUI, and I open another thread to do network communications. It turned out that if you create a wx.Frame & make it show up, then your time.sleep may sleep l

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-18 Thread Marko Rauhamaa
crow : > I'm writing some scripts with python, and I found sometimes, when I > try to use time.sleep(1) to sleep 1 sec, it would actually sleep for 9 > secs or even longer. > > [...] > > So, my question: under what kind of condition, time.sleep would > suspend longer time than expected? That coul

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-18 Thread Chris Angelico
On Wed, Jun 18, 2014 at 7:52 PM, crow wrote: > So, my question: under what kind of condition, time.sleep would suspend > longer time than expected? > > Anybody got interested? There are several reasons the sleep time is always described as "at least" that long. Firstly, your process will always

Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-18 Thread crow
Hi. I'm writing some scripts with python, and I found sometimes, when I try to use time.sleep(1) to sleep 1 sec, it would actually sleep for 9 secs or even longer. >From python document, I saw this: time.sleep(secs) Also, the suspension time may be longer than requested by an arbitrary amo