def enable_autocomplete_and_history(adir,env):
    try:
        import rlcompleter
        import atexit
        import readline
    except __HOLE__:
        pass
    else:
        readline.parse_and_bind("bind ^I rl_complete"
                                if sys.platform == 'darwin'
                                else "tab: complete")
        history_file = os.path.join(adir,'.pythonhistory')
        try:
            readline.read_history_file(history_file)
        except IOError:
            open(history_file, 'a').close()
        atexit.register(readline.write_history_file, history_file)
        readline.set_completer(rlcompleter.Completer(env).complete)
dataset/ETHPy150Open uwdata/termite-data-server/web2py/gluon/shell.py/enable_autocomplete_and_history