try: import readline, rlcompleter if os.path.exists(histfile): readline.read_history_file(histfile) readline.parse_and_bind("tab: complete") import atexit atexit.register(readline.write_history_file, histfile) del readline, rlcompleter, atexit except (ImportError,AttributeError): pass del os,histfile