On this page
  1. readline.read_history_file
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

readline.read_history_file

Prev: readline.parse_and_bind | Up: readline | Next: readline.read_init_file
Rel: readline.add_history, readline.clear_history, readline.get_begidx, readline.get_completer
Ref: docs.python.org — readline.read_history_file
Tags: #public #python3 #stdlib #readline


Import

import readline
from readline import read_history_file

Signature & Overview

readline.read_history_file(filename=None, /)

Load a readline history file.

Usage

import readline
from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as tmp:
    p = Path(tmp) / 'hist'
    p.write_text('echo hi\n', encoding='utf-8')
    readline.clear_history()
    readline.read_history_file(str(p))
    assert readline.get_current_history_length() >= 1

Gotchas

REPL Inspect

from readline import read_history_file
help(read_history_file)

Linked from

Related notes