Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'args': 0.07; 'subject:would': 0.07; 'suppose': 0.07; 'arguments': 0.09; 'parsing': 0.09; 'url:github': 0.09; 'windows,': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'gui': 0.12; 'assume': 0.14; 'wrote': 0.14; 'windows': 0.15; '.py': 0.16; 'advice:': 0.16; 'does,': 0.16; 'expert,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'idle,': 0.16; 'subject: \n ': 0.16; 'think.': 0.16; 'ui,': 0.16; 'version;': 0.16; 'worst': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'file,': 0.19; 'thu,': 0.19; 'typing': 0.19; 'command': 0.22; 'cc:addr:python.org': 0.22; 'script.': 0.24; 'typical': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; 'compare': 0.26; 'possibly': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'installed': 0.27; 'tried': 0.27; 'idea': 0.28; 'chris': 0.29; 'room': 0.29; 'subject:) ': 0.29; 'unix': 0.29; 'message- id:@mail.gmail.com': 0.30; 'easier': 0.31; '(although': 0.31; 'os,': 0.31; 'subject:what': 0.31; 'file': 0.32; 'probably': 0.32; 'figure': 0.32; 'run': 0.32; 'quite': 0.32; 'open': 0.33; 'linux': 0.33; 'framework': 0.33; 'mac': 0.33; 'maybe': 0.34; "can't": 0.35; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'interaction': 0.36; "didn't": 0.36; 'subject:?': 0.36; 'similar': 0.36; 'christian': 0.38; 'massive': 0.38; 'skip:[ 10': 0.38; 'pm,': 0.38; 'bad': 0.39; 'system.': 0.39; 'how': 0.40; 'even': 0.60; 'easy': 0.60; 'simple,': 0.60; "you're": 0.61; 'first': 0.61; "you'll": 0.62; "you've": 0.63; 'real': 0.63; 'provide': 0.64; 'more': 0.64; 'different': 0.65; 'situation': 0.65; 'talking': 0.65; 'phone': 0.66; 'series': 0.66; 'night,': 0.68; 'prompt': 0.68; 'fact,': 0.69; 'long-term': 0.74; 'ever.': 0.84; 'seldom': 0.84; 'url:master': 0.84; 'subject:much': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=G+3wSZzdW2AuN54FtxC0Fv3IW/xgAmou4hTRgZBDL4I=; b=UzuI5Dv1PF1TLeqfOCeVnLzDQZO8QCDUeklihypRid7dXPRBtikSlC82vqsFOejrEH L5yKaC16N9EB0QhUwZDERoiWFS24n4asdZW79n3iXCQK4aZ4aey0Kta7bsQ4jbCFiue3 eLBxDIGc/xNZ2XqRk2Qogio0wrxQX4LY8YQKm3RZV8BRiHbTmnLk2S80cbVPJats2c1s FMsRetyh1imaCvXA1t1kH5zcvFPYwSb+EBCl5NkKmIyPGIVBbCs2m5JSV4pz6zvTFc27 VF/AwdJWv7X0Ok3UpkYBM2lrGuAtU8oOXtJSkA7t5f3/CizJmxzIzRRyS5a32fAHGLwE N4Rg== MIME-Version: 1.0 X-Received: by 10.58.56.71 with SMTP id y7mr2715783vep.24.1403163765384; Thu, 19 Jun 2014 00:42:45 -0700 (PDT) In-Reply-To: References: <713f4189-5ffe-492d-9c7d-447bb4b4928a@googlegroups.com> <4d7c474a-b88e-4dea-b74c-ed34f4969310@googlegroups.com> Date: Thu, 19 Jun 2014 17:42:45 +1000 Subject: Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1403163773 news.xs4all.nl 2838 [2001:888:2000:d::a6]:57198 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73401 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 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