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

Christian Gollwitzer auriocus at gmx.de
Thu Jun 19 13:17:09 EDT 2014


Am 19.06.14 09:42, schrieb Chris Angelico:
> On Thu, Jun 19, 2014 at 5:18 PM, Christian Gollwitzer <auriocus at gmx.de> 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....

> I disagree. It may not be the *best* console UI, but it's not as bad
> as you think. Yes, what I wrote was a massive oversimplification, but
> compare this:
>
> https://github.com/Rosuav/runningtime/blob/master/runningtime.py#L44
>
> That's a simple, straight-forward UI. If you put the .py file onto
> your desktop and double-click it, you'll see a series of prompts, and
> this works on Windows, OS/2, probably Mac OS, and quite a few Linux
> desktops.

While I don't understand the purpose of the program (is it a game?), it 
shows exactly why this is a bad idea. Here is my try (OSX):

Apfelkiste:Tests chris$ python runningtime.py
Enter track length in m: 20
Enter speed limit [400km/h]: 300
Enter track length in m: 10
Enter speed limit [400km/h]: 100
Enter track length in m: 0
()
[  0.00] Power
[  7.85] Enter next section (10m speed 100)
[  8.00] Cruise
[  9.49] Enter next section (0m speed 0)
Traceback (most recent call last):
   File "runningtime.py", line 205, in <module>
     nextsection, nextspeed = next(section)
StopIteration

Suppose I want to run it again, but have length 30 in the first step.

1.)How am I going to do this? I have to restart it and key in 4 numbers, 
whereas I only wanted to change 1. Now let that be 10 segments.

2.) There is no way to save the input or the result. Or it may not be 
obvious. I could prepare a file with the numbers, then do

	python runningtime.py <input > output
But then I don't see the prompts and have to be careful not to enter a 
speed for a length.

3.) The program doesn't tell me how to break out of the entering process 
and start the computation. Is it a 0? Is it an empty string? I'm getting 
Tracebacks in either case (could be wrong python version, I'm using the 
OSX default 2.7.2)

All these problems arise because the program forces me to enter the data 
in a predefined sequence. So no, this is not a good user experience. In 
a GUI it would be trivial to have an editable listbox for track length 
and speed, and a set of buttons to save, load, run the computation.

	Christian



More information about the Python-list mailing list