Saving history in interactive Python

Bruce Edge bedge at troikanetworks.com
Wed Mar 21 10:32:18 EST 2001


set /home/<logname>/.python, then here's what I stuck in my ~/.python
file


histfile="/home/<logname>/.python
import rlcompleter
import readline
readline.parse_and_bind("M-?: complete")
readline.parse_and_bind("tab: menu-complete")
import os
import sys
readline.read_history_file( histfile )
def savehist():
	global histfile
	readline.write_history_file( histfile )
import atexit
atexit.register( savehist )	


This gets you command history saving, and readline command line editing.

-Bruce.


Timothy Grant wrote:
> 
> Is there a way to save the history list in the Python
> interpreter.
> 
> --
> Stand Fast,
>     tjg.
> 
> Timothy Grant                         tjg at exceptionalminds.com
> Red Hat Certified Engineer            www.exceptionalminds.com
> Avalon Technology Group, Inc.         <><       (503) 246-3630
> >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<
> >>>>This machine was last rebooted:  62 days 22:52 hours ago<<



More information about the Python-list mailing list