Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73401

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

References <713f4189-5ffe-492d-9c7d-447bb4b4928a@googlegroups.com> <mailman.11114.1403087670.18130.python-list@python.org> <4d7c474a-b88e-4dea-b74c-ed34f4969310@googlegroups.com> <mailman.11128.1403134697.18130.python-list@python.org> <lnu2sb$r3d$1@dont-email.me>
Date 2014-06-19 17:42 +1000
Subject Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.11135.1403163773.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Jun 19, 2014 at 5:18 PM, Christian Gollwitzer <auriocus@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....
>
> 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 in IPython (Example: SciPy)
>
> 3) Use a real GUI framework
>
> It turns out, that 3) is actually not only easier to use, but often easier
> to write than 1)

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. (Although I didn't put a shebang on that file, so it might
not work on your typical Linux.) How do you make something that
provides command line arguments to a double-clicked-on icon? Different
for every platform. (And seldom as easy as it is on OS/2.) If you run
that in a terminal, you'll see a series of prompts, and it works on
probably every Python implementation EVER. If you pull it up in IDLE,
it'll probably work there too, although I haven't tried it.

You're quite right that parsing the command line is often better for
long-term usability. But you try explaining to someone how to provide
args to a script. In fact, let's go a bit further: You can't assume
that Python was installed in any particular way, you've been told that
the OS is some version of Windows you're not familiar with (if you're
a Windows expert, then suppose this is some version of Mac OS that
you've never touched), and you're talking to the person over the
phone. This is, in fact, very similar to the situation I was in last
night, except that I wasn't even the person on the phone - my sister
was, and I was in the same room as she was. Now, you have no idea
whether typing "foo.py" will run it in Python, and if it does, in what
version; you have no idea whether "python.exe" is in PATH; and you
possibly can't even figure out how to open up a command prompt on that
system.

Yeah, I think [raw_]input() isn't so bad after all.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? crow <wentlv@gmail.com> - 2014-06-18 02:52 -0700
  Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Marko Rauhamaa <marko@pacujo.net> - 2014-06-18 13:30 +0300
  Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Chris Angelico <rosuav@gmail.com> - 2014-06-18 20:34 +1000
    Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? crow <wentlv@gmail.com> - 2014-06-18 08:24 -0700
      Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Chris Angelico <rosuav@gmail.com> - 2014-06-19 09:38 +1000
        Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? crow <wentlv@gmail.com> - 2014-06-18 18:41 -0700
          Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Chris Angelico <rosuav@gmail.com> - 2014-06-19 13:58 +1000
        Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Christian Gollwitzer <auriocus@gmx.de> - 2014-06-19 09:18 +0200
          Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Chris Angelico <rosuav@gmail.com> - 2014-06-19 17:42 +1000
            Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Marko Rauhamaa <marko@pacujo.net> - 2014-06-19 12:20 +0300
            Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Christian Gollwitzer <auriocus@gmx.de> - 2014-06-19 19:17 +0200
              Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Chris Angelico <rosuav@gmail.com> - 2014-06-20 08:57 +1000
          Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Terry Reedy <tjreedy@udel.edu> - 2014-06-19 22:33 -0400
          Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? Chris Angelico <rosuav@gmail.com> - 2014-06-20 12:54 +1000

csiph-web