[Python] How to tell Python to stop writing history file

Discussão em 'Python' iniciado por Stack, Março 10, 2025.

  1. Stack

    Stack Membro Participativo

    How to tell Python to stop writing the history file .python_history?

    In my .bashrc, I have

    export PYTHONSTARTUP="${HOME}/py_startup.py"


    In the py_startup.py file, I have

    import math
    import readline

    readline.write_history_file = lambda *args: None


    I can confirm that Python is loading the py_startup.py file and executing its content. But it is still creating .python_history when I close the Python REPL with Ctrl-D.

    Python version: 3.13.2; OS: Arco linux; WM: i3wm.

    Continue reading...

Compartilhe esta Página