On Thu, 2005-10-27 at 04:34 +0200, guy keren wrote: > the problem with writing things via the interactive prompt, is that they > "go away" when you log out. you can't look at a listing of your code (or > can you?) - you cannot re-edit a function (or can you?). > You can, see below. You can have persistent history in a simple text file. You can have multi-line editing, which allows recalling a whole function or class definition and editing it.
This still doesn't save the output - but working with scripts doesn't save it either. script(1) helps. > On Tue, 25 Oct 2005, Beni Cherniavsky wrote: > > > If you don't have enough experience with Python's interactive prompt, > > you might not realise its power yet.When experimenting with Python > > code it's much more convenient than the shell.Heavily relying on > > interactive work calls all the stronger for an IDE (like IDLE).If you > > are really limited to a textual terminal, there are still some nice > > environments (e.g. ipython).I'll study the offerings and give a > > reccomendation soon.Perhaps I will even adjust the editor/prompt > > keybindings to match one another. > > please check them and see if they fit the bill. i have some personal > disliking for IDEs generally - but if the IDE does not hide the program's > structure, and does not require too much teaching, i'll consider using it > for the course. > Here are the offerings for a *nix terminal: readline+rlcompleter http://docs.python.org/lib/module-rlcompleter.html + Builtin with python (you just have to enable completion). - Only does single-line editing with basic completion. No reason not to use it - this is the comparison baseline. rlcompleter2 http://codespeak.net/rlcompleter2/ + Really smart completion anywhere (modules, keywords) + Quick help - shows docstrings on repeated <tab> presses. + History is persistent between runs. + Trivial format - you can cut-and-paste from ~/.pythonhist - Still single-line editing, heavy completion clutters screen. I think this is a definite improvement compared to the builtin rlcompleter. Go for it unless you go for somethings heavier. pyrepl http://codespeak.net/pyrepl/ + Good multi-line editing! Can recall a whole loop or def, edit and re-run it. + Cleans up screen after completion - only commands and results remain. + History is persistent between runs. - Slow startup - above 2 seconds. - Only basic completion, no help access. - Prompt slighlty different. No big deal. - Uses terminfo. Won't work with native windoze build. Who cares. - ``script -c pythoni`` doesn't work. But it can be emulated from within python - logging sys.std{in,out,err} is very easy. I think this is the one we want. Multi-line editing is the number-one feature that makes an interactive prompt useful. A clean screen will also help students. IPython + Fancy, colorful Mathematica-like prompt - Doesn't quite feel like a Python prompt any longer + Lots of magic features (e.g. ways to omit parens in calls, macros, calling shell commands). - Might confuse students + Nice help interface. Can even show source code with hightlighting - now *that's* showing off :-) + History is persistent between runs. + Trivial format - you can cut-and-paste from ~/.pythonhist - Only single-line editing and basic completion. I think this is not suitable for us. Advanced users might like it but it's too different from vanilla python and has too many features for begining students. So I think perepl is best, rlcompleter2 is second best. /me wanders how many hours will it take to make to merge rlcompleter2 into pyrepl... (but don't hold your breath) P.S. Here is my $PYTHONSTARTUP setup to try them all:: # pyrepl/IPython are executed from command-line # (as ``pythoni``/``ipython`` respectively) if not ('pyrepl' in sys.modules or 'IPython' in sys.modules): try: import rlcompleter2 rlcompleter2.setup() del rlcompleter2 except ImportError: try: import rlcompleter, readline readline.parse_and_bind("tab: complete") del rlcompleter, readline except ImportError: pass
