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 something in in the predefined order of the program. I've never seen
a useful mature program working like that, only courseware and maybe
crufty FORTRAN stuff from the past.
Unless there is good reason, make your program read the data from the
command line args and from files given on the command line. This solves
a lot of problems with user interaction, e.g. repeating and correcting
commands. Programs written in the input() style are very annoying when
you made a mistake in the 21st parameter of 30. Good interactive command
line tools (e.g. gnuplot, Matlab, IPython, ...) exist, but they are
complex; they bind to a readline library and implement a complex command
language.
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)
Christian
--
https://mail.python.org/mailman/listinfo/python-list