On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > goldtech <goldt...@worldpost.com> writes: > >> Using Windows. Is there a python shell that has a history of typed in >> commands? > > I don't know about MS Windows, but the Python interactive shell can be > linked with the GNU Readline library for managing its command line > <URL:http://docs.python.org/library/readline.html> including editing > features, tab completion, history management, and a persistent history > file. > > You can then use that functionality in your Python interactive startup > file. Here's mine: > > ===== > # $HOME/.pythonrc > # User configuration for interactive Python shell. > > import sys > import os > import os.path > import atexit > > # Tab completion with readline. > # Cribbed from <URL:http://docs.python.org/lib/module-rlcompleter.html>. > try: > import readline > except ImportError: > sys.stderr.write("Module readline not available.\n") > else: > import rlcompleter > > # Enable tab completion. > readline.parse_and_bind("tab: complete") > > # Persistent command history. > histfile = os.path.join(os.environ["HOME"], ".python_history") > try: > readline.read_history_file(histfile) > except IOError: > # Existing history file can't be read. > pass > atexit.register(readline.write_history_file, histfile) > > del histfile > > del sys, os, atexit > > ===== > > Reading the documentation, I see that the ‘readline’ library is only > linked with Python on Unix-alike operating systems. Yet another reason > why MS Windows is not a good choice for developing software I guess.
I'm not sure what documentation you're reading, but your code works fine on Windows. Thanks. [It is necessary to properly set PYTHONSTARTUP] -- http://mail.python.org/mailman/listinfo/python-list