On Thu, Jun 19, 2014 at 5:18 PM, Christian Gollwitzer <aurio...@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 -- https://mail.python.org/mailman/listinfo/python-list