GNU Info

Info Node: (python2.1-lib.info)Example 6

(python2.1-lib.info)Example 6


Prev: readline Up: readline
Enter node , (file) or (file)node

Example
-------

The following example demonstrates how to use the `readline' module's
history reading and writing functions to automatically load and save a
history file named `.pyhist' from the user's home directory.  The code
below would normally be executed automatically during interactive
sessions from the user's `PYTHONSTARTUP' file.

     import os
     histfile = os.path.join(os.environ["HOME"], ".pyhist")
     try:
         readline.read_history_file(histfile)
     except IOError:
         pass
     import atexit
     atexit.register(readline.write_history_file, histfile)
     del os, histfile


automatically generated by info2www version 1.2.2.9